Allow renaming of towns during gameplay

This commit is contained in:
Ted John 2018-01-11 21:47:12 +00:00
parent 6d63e99f6d
commit badfb2c76b
7 changed files with 52 additions and 0 deletions

4
CHANGELOG.md Normal file
View File

@ -0,0 +1,4 @@
0.1.0 (in development)
------------------------------------------------------------------------
- Feature: Towns can now always be renamed (As seen in OpenTTD).
- Feature: Playable in a resizable window.

View File

@ -48,6 +48,13 @@ void register_hooks()
return 0;
});
register_hook(0x00498E9B,
[](registers &regs) -> uint8_t
{
openloco::ui::windows::sub_498E9B((openloco::ui::window *)regs.esi);
return 0;
});
// Remove the set window pos function, we do not want it as it
// keeps moving the process window to 0, 0
// Can be removed when windowmgr:update() is hooked

View File

@ -63,6 +63,11 @@ namespace openloco
return glpCmdLine;
}
bool is_editor_mode()
{
return (_screen_flags & screen_flags::editor) != 0;
}
bool is_paused()
{
return paused_state;

View File

@ -16,6 +16,8 @@ namespace openloco
void * hInstance();
const char * lpCmdLine();
bool is_editor_mode();
bool is_paused();
void prompt_tick_loop(std::function<bool()> tickAction);
void sub_48A18C();

View File

@ -33,6 +33,7 @@
<ClCompile Include="windows\promptbrowsewnd.cpp" />
<ClCompile Include="windows\promptokcancelwnd.cpp" />
<ClCompile Include="windows\textinputwnd.cpp" />
<ClCompile Include="windows\townwnd.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="audio\audio.h" />

View File

@ -42,8 +42,12 @@ namespace openloco::ui::windows
save = 2
};
window * open_town_window(uint16_t townId);
void sub_498E9B(window * w);
bool prompt_browse(browse_type type, char * path, const char * filter, const char * title);
bool prompt_ok_cancel(string_id okButtonStringId);
}
namespace openloco::ui::textinput

View File

@ -0,0 +1,29 @@
#include "../interop/interop.hpp"
#include "../openloco.h"
#include "../windowmgr.h"
namespace openloco::ui::windows
{
// 0x00498E9B
void sub_498E9B(window * w)
{
w->enabled_widgets |= 2;
#ifdef _DISABLE_TOWN_RENAME_
if (is_editor_mode())
{
w->enabled_widgets &= ~2;
}
#endif
}
// 0x00446F6B
// dx: townId
// esi: {return}
window * open_town_window(uint16_t townId)
{
registers regs;
regs.dx = townId;
LOCO_CALLPROC_X(0x00446F6B, regs);
return (window *)regs.esi;
}
}