GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Change x,y->Point w,h->Extent by morganchristiansson · Pull Request #40 · Return-To-The-Roots/s25edit

Conversation

@morganchristiansson

@morganchristiansson morganchristiansson commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Based on this comment #37 (review)

Replace raw x,y and w,h parameters with Position and Extent types across
CMap, CSurface, CControlContainer, CButton, CPicture, CTextfield, and
CFont to make X/Y vs W/H semantics explicit and prevent copy-paste errors.

  • CMap/CSurface: vertex/modification methods take Position pos instead
    of separate int x, int y / int VertexX, VertexY / Uint16 MouseX, MouseY
  • CControlContainer: addButton/addText/addPicture/addStaticPicture/addTextfield
    take Point16 pos / Extent16 size (consistent with addSelectBox)
  • CButton/CPicture/CTextfield/CFont: constructors take Point16 pos /
    Extent16 size with internal storage renamed to pos_/size_
  • All call sites in callbacks.cpp and CDebug.cpp updated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@morganchristiansson
morganchristiansson force-pushed the xy-point-extent branch 4 times, most recently from a2e78ad to 276f709 Compare June 18, 2026 13:02
@morganchristiansson
Use Position/Extent for x,y/w,h values
a47e263
@morganchristiansson
morganchristiansson force-pushed the xy-point-extent branch from 276f709 to a47e263 Compare June 18, 2026 13:06
Flow86
Flow86 reviewed Jun 18, 2026
View reviewed changes
Comment thread CIO/CButton.cpp Outdated
Comment on lines +16 to +17
this->pos_ = pos;
this->size_ = size;

@Flow86 Flow86 Jun 18, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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

@morganchristiansson morganchristiansson Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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
Comment thread CIO/CButton.cpp Outdated
{
// 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((motion.x >= pos_.x) && (motion.x < pos_.x + size_.x) && (motion.y >= pos_.y) && (motion.y < pos_.y + size_.y))

@Flow86 Flow86 Jun 18, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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

@morganchristiansson morganchristiansson Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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
Comment thread CIO/CButton.cpp Outdated
}
} else if(button_text)
CFont::writeText(Surf_Button, button_text, (int)w / 2, (int)((h - 11) / 2), FontSize::Medium, button_text_color,
CFont::writeText(Surf_Button, button_text, Position((int)size_.x / 2, (int)((size_.y - 11) / 2)), FontSize::Medium, button_text_color,

@Flow86 Flow86 Jun 18, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C cast still necessary? if so, replace by static_cast instead

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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
Comment thread CIO/CPicture.h Outdated
#pragma once

#include "SdlSurface.h"
#include "defines.h"

@Flow86 Flow86 Jun 18, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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

@morganchristiansson morganchristiansson Jun 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed because CPicture.h uses Point16 and Extent16 types for the new pos_ and size_ member
variables:

Point16 pos_;
Extent16 size_;

These typedefs are defined in defines.h:

using Point16 = Point<Sint16>;
using Extent16 = Point<Uint16>;

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread callbacks.cpp

@Flow86 Flow86 Jun 18, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can't be rendered on github - what the heck happened?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me. But it's very large diff :-D

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Flamefire reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Your Name added 3 commits June 18, 2026 15:26
Your Name
Merge branch 'master' into xy-point-extent
001edc8
Your Name
Fix GH actions failure
442eeec
Your Name
Apply PR feedback: init lists, IsPointInRect, static_cast, cleanup
fecdae7
Flamefire
Flamefire reviewed Jun 18, 2026
View reviewed changes
Comment thread CIO/CButton.cpp Outdated
}
} 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),

@Flamefire Flamefire Jun 18, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Flamefire
Flamefire reviewed Jun 18, 2026
View reviewed changes
Comment thread callbacks.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Flamefire
Flamefire reviewed Jun 18, 2026
View reviewed changes
Comment thread CIO/CButton.cpp Outdated
{
// 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_))))

@Flamefire Flamefire Jun 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Your Name added 3 commits June 18, 2026 16:18
Your Name
Remove unnecessary static_cast<int> casts
be4e71f
Your Name
Fix GH actions failure
8a46597
Your Name
Merge remote-tracking branch 'upstream/master' into xy-point-extent
e94fd30
@morganchristiansson morganchristiansson mentioned this pull request Jun 18, 2026
s25edit backports from s25client #37
Open
@morganchristiansson
morganchristiansson requested review from Flamefire and Flow86 June 22, 2026 23:36
@morganchristiansson

morganchristiansson commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@morganchristiansson morganchristiansson mentioned this pull request Jun 22, 2026
Align USD texture offset on even rows with s25client #48
Draft
@Flamefire

Flamefire commented Jun 23, 2026

Copy link
Copy Markdown
Member

There is an open question

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Flamefire
Flamefire requested changes Jun 23, 2026
View reviewed changes

@Flamefire Flamefire left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, thanks. 2 things:

  • Offsets should be signed. It could use a typedef like using Offset = Point<int> for clarity.
  • Lot's of introduced casts. Double-check where they are actually required. Many look uneccessary to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread CIO/CFile.cpp Outdated
// 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++)

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread CIO/CButton.cpp Outdated
// position in the Surface 'Surf_Button'
Uint16 pos_x = 0;
Uint16 pos_y = 0;
unsigned pos_x = 0;

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The 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
Comment thread CIO/CPicture.h Outdated
#pragma once

#include "SdlSurface.h"
#include "defines.h"

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread CIO/CSelectBox.cpp Outdated
// position in the Surface 'Surf_Button'
Uint16 pos_x = 0;
Uint16 pos_y = 0;
unsigned pos_x = 0;

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread CIO/CTextfield.cpp Outdated
@@ -340,45 +340,45 @@ bool CTextfield::render()
// black frame is left and up
// draw vertical line
pos_x = 0;

@Flamefire Flamefire Jun 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@morganchristiansson morganchristiansson Jun 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread CSurface.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

morganchristiansson and others added 2 commits June 23, 2026 15:59
@morganchristiansson
Push Position/Extent all the way to SDL boundary
7e38250
@morganchristiansson
Address PR feedback: Position usage, signed offset, loop cleanup
89c0f88
@morganchristiansson
morganchristiansson force-pushed the xy-point-extent branch from f179a30 to 89c0f88 Compare June 23, 2026 13:59
@morganchristiansson

morganchristiansson commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

(force pushed to apply clang-format to previously pushed commit)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

morganchristiansson added 2 commits June 23, 2026 17:26
@morganchristiansson
Fix duplicate pic variable
d8647dd
@morganchristiansson
Merge remote-tracking branch 'upstream/master' into xy-point-extent
384b53d
@morganchristiansson
morganchristiansson force-pushed the xy-point-extent branch from 9583ae4 to 384b53d Compare June 23, 2026 15:29
@morganchristiansson

morganchristiansson commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Please can we keep pushing this one as it will cause conflicts with other PRs

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Flamefire
Flamefire merged commit 2ef8ed5 into Return-To-The-Roots:master Jun 25, 2026
1 check passed

Uh oh!

There was an error while loading. Please reload this page.

FlexApex added a commit to FlexApex/s25edit that referenced this pull request Jun 28, 2026
@FlexApex
Fix build: reconcile rebase conflicts with upstream PR Return-To-The-…
faf9641
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Flamefire Flamefire Flamefire requested changes
@Flow86 Flow86 Awaiting requested review from Flow86

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@morganchristiansson @Flamefire @Flow86
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.