Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paintTileMapPort to support world map tile painting (Develop) #4767

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Crystalwarrior
Copy link
Contributor

@Crystalwarrior Crystalwarrior commented Jun 29, 2024

You are now able to paint world map tiles!

339553943-1455e289-be0d-4320-b533-8e16aa689f8a

Closes #4703

Split up doSetTile_char() and doGetTile_char() for non-graphics mode tile grabbing
return true;
}

static bool doSetTile_map_port_default(const Pen &pen, int x, int y, int32_t * df::graphic_map_portst::*texpos_field) {
Copy link
Member

Choose a reason for hiding this comment

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

The purpose of doSetTile_default() is to enable GuiHooks - it's the default implementation called if no hooks are defined. Since you don't appear to be worried about GuiHooks for your new functions (which is probably fine), you can likely drop the _default functions.

Also, I would opt for consistent capitalization within function names, e.g. doSetTileMapPort or doSetMapPortTile. The _default suffix is a special case for GuiHooks, to indicate we're defining "our" default implementation of a function that could be overridden.

@myk002
Copy link
Member

myk002 commented Jun 30, 2024

which maps does this cover?
is it all of them?
embark, fort->world, adventure->travel->mid, and adventure->travel->full?

Comment on lines +3079 to +3080
{ "paintTileMapPort", screen_paintTileMapPort },
{ "readTileMapPort", screen_readTileMapPort },
Copy link
Member

Choose a reason for hiding this comment

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

needs docs in Lua API.rst

if (lua_gettop(L) >= 4 && !lua_isnil(L, 4))
{
if (lua_type(L, 4) == LUA_TSTRING)
pen.ch = lua_tostring(L, 4)[0];
Copy link
Member

Choose a reason for hiding this comment

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

what if it's a zero-length string?

Copy link
Member

@lethosor lethosor Jul 1, 2024

Choose a reason for hiding this comment

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

It will still be safe, since the string is null-terminated, but it will set pen.ch to 0, which may or may not be what you want.

Comment on lines +442 to +443
if (tile == 0)
tile = vp->screentexpos_interface[index];
Copy link
Member

Choose a reason for hiding this comment

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

this should be checked first since it is the "default" layer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new map drawing functions
3 participants