GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Change x,y->Point w,h->Extent by morganchristiansson · Pull Request #40 · Return-To-The-Roots/s25edit Conversation
Contributor
Based on this comment #37 (review) Replace raw x,y and w,h parameters with Position and Extent types across
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
morganchristiansson
force-pushed
the
xy-point-extent
branch
4 times, most recently
from
a2e78ad to
276f709
Compare
morganchristiansson
force-pushed
the
xy-point-extent
branch
from
276f709 to
a47e263
Compare
Flow86
reviewed
Comment on lines
+16
to
+17
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please put those directly into the constructors initializer list for new code. In this case it doesnt change any relevant order.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we also had something like this in the code IsPointInExtent or so
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IsPointInExtent is now used
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C cast still necessary? if so, replace by
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cast removed.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed here?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||
| } else if(button_text) | ||
| CFont::writeText(Surf_Button, button_text, Position((int)size_.x / 2, (int)((size_.y - 11) / 2)), | ||
| CFont::writeText(Surf_Button, button_text, Position(static_cast<int>(size_.x) / 2, static_cast<int>(size_.y - 11) / 2), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why is the cast required?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
cast removed.
AI loves adding casts unfortunately.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| { | ||
| // cursor is on the button (and mouse button not pressed while moving on the button) | ||
| if((motion.x >= x_) && (motion.x < x_ + w) && (motion.y >= y_) && (motion.y < y_ + h)) | ||
| if(IsPointInRect(Position(motion.x, motion.y), Rect(Position(pos_), Extent(size_)))) |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why the cast (Position(pos_))? Should work directly, doesn't it?
Similar below?
If it cannot convert the Point16 to Position automatically then I'd say we should store them as Position/Extent. I mentioned that earlier that in almost all cases the default is fine instead of the sized-variants. As this seems to be an automatic conversion there is no real need to change that too, but if it causes issues like here(?) then it makes sense to change it at least for this class
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
CButton.cpp: size_ is Extent16 = Point. Uint16 implicitly promotes to int for arithmetic (standard
integral promotion), and Position(int, int) accepts the promoted values directly. So Position(size_.x / 2,
(size_.y - 11) / 2) works fine.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Do you want to go ahead and change ALL Point16 to Position in the codebase and remove Point16 type?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
At least where it requires extra work like here.
I'm not sure if there is any use of the sized Point types, maybe in some file operations. But generally the ~4 extra bytes per control/window don't matter (anymore), so yes it makes sense to replace them to make them easier to handle and reason about
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok went all the way and pushed usage of Point/Extent in UI mainly all the way to the C SDL functions.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Can we get this one out of the way? It's a pure refactor that doesn't make any changes and there's no reason for it to sit in queue. I stupidly based another branch on this thinking it would be quick to merge. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There is an open question |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Better, thanks. 2 things:
using Offset = Point<int> for clarity.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // read start addresses | ||
| for(int y = 0; y < shadowArray->h; y++) | ||
| CHECK_READ(libendian::le_read_us(&starts[y], fp)); | ||
| for(Position pos{0, 0}; pos.y < shadowArray->h; pos.y++) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You don't like Position in for loop?
Was originally going to leave for loops alone, but there's a lot of x, y usage in them and this is actually nice I think.
But hmm this is CFile, not UI. Maybe should not convert CFile. There was bug with unitialized pos from changes here.
And why is CFile in same folder as all UI classes anyway.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In this loop you loop over y only, so that's not a position
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ok reverted the y-only loop. Kept Positio for x,y loops.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // position in the Surface 'Surf_Button' | ||
| Uint16 pos_x = 0; | ||
| Uint16 pos_y = 0; | ||
| unsigned pos_x = 0; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why not convert those too?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| #pragma once | ||
|
|
||
| #include "SdlSurface.h" | ||
| #include "defines.h" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can now be removed again, can't it?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // position in the Surface 'Surf_Button' | ||
| Uint16 pos_x = 0; | ||
| Uint16 pos_y = 0; | ||
| unsigned pos_x = 0; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Convert?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Converted
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -340,45 +340,45 @@ bool CTextfield::render() | |||
| // black frame is left and up | |||
| // draw vertical line | |||
| pos_x = 0; | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Those variable values can be inlined (Position(0, y))
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
inlined to expressions
- pos_x = size_.x - 1; for(unsigned y = 0; y < size_.y; y++) - CSurface::DrawPixel_RGB(Surf_Text, Position(pos_x, y), 0, 0, 0); + CSurface::DrawPixel_RGB(Surf_Text, Position(size_.x - 1, y), 0, 0, 0);
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
f179a30 to
89c0f88
Compare
|
(force pushed to apply clang-format to previously pushed commit) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
9583ae4 to
384b53d
Compare
|
Please can we keep pushing this one as it will cause conflicts with other PRs |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…Roots#42 Position API After rebasing the feature branch onto upstream master (which merged PR Return-To-The-Roots#40 xy-point-extent and PR Return-To-The-Roots#42 menu-windows), several files had stale int-based API calls/definitions that conflicted with the new Position/Extent API: - CGame.h: add missing enterEditor/LoadSettings/SaveSettings declarations and suppressResizeEvents_ member (implemented in CGame.cpp from the resizable-window commit but omitted from the header during rebase) - globals.h: add TRIANGLE_HEIGHT/WIDTH/INCREASE macro aliases for the lowercase mutable globals used by CGame_Event.cpp and CSurface.cpp - CSurface.cpp: restore Position-based signatures for Draw, DrawPixel_*, GetPixel, update_shading, update_flatVectors, update_nodeVector to match CSurface.h (PR Return-To-The-Roots#42 API); keep the tiling additions (floorDiv, drawTriangleTiled, new DrawTriangleField loop) from the resizable commit - callbacks.cpp: rebuild EditorLoadMenu folder navigation on top of the PR Return-To-The-Roots#42 Position API (no int-based addText/addButton calls)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.