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

[Gui] clarify representation of squad panel UI states #4980

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Template for new versions:
- ``dfhack.units``: new function ``setPathGoal``

## Removed
- UI focus strings for squad panel flows combined into a single tree: ``dwarfmode/SquadEquipment`` -> ``dwarfmode/Squads/Equipment``, ``dwarfmode/SquadSchedule`` -> ``dwarfmode/Squads/Schedule``

# 50.14-r1

Expand Down
84 changes: 49 additions & 35 deletions library/modules/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ static std::map<virtual_identity*, getFocusStringsHandler> getFocusStringsHandle

#define VIEWSCREEN(name) df::viewscreen_##name##st
#define DEFINE_GET_FOCUS_STRING_HANDLER(screen_type) \
static void getFocusStrings_##screen_type(std::string &baseFocus, std::vector<std::string> &focusStrings, VIEWSCREEN(screen_type) *screen);\
static void getFocusStrings_##screen_type(const std::string &baseFocus, std::vector<std::string> &focusStrings, VIEWSCREEN(screen_type) *screen);\
DFHACK_STATIC_ADD_TO_MAP(\
&getFocusStringsHandlers, &VIEWSCREEN(screen_type)::_identity, \
(getFocusStringsHandler)getFocusStrings_##screen_type \
); \
static void getFocusStrings_##screen_type(std::string &baseFocus, std::vector<std::string> &focusStrings, VIEWSCREEN(screen_type) *screen)
static void getFocusStrings_##screen_type(const std::string &baseFocus, std::vector<std::string> &focusStrings, VIEWSCREEN(screen_type) *screen)

DEFINE_GET_FOCUS_STRING_HANDLER(title)
{
Expand Down Expand Up @@ -258,7 +258,7 @@ DEFINE_GET_FOCUS_STRING_HANDLER(world)
}

static bool widget_is_visible(df::widget * w) {
return w && w->flag.bits.WIDGET_VISIBILITY_VISIBLE;
return w && w->flag.bits.VISIBILITY_VISIBLE;
}

static size_t get_num_children(df::widget * w) {
Expand Down Expand Up @@ -327,15 +327,9 @@ static void add_profile_tab_focus_string(
focusStrings.push_back(fs);
}

DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
{
static void add_main_interface_focus_strings(const string &baseFocus, vector<string> &focusStrings) {
std::string newFocusString;

if (df::global::gametype && !World::isFortressMode()) {
newFocusString = baseFocus;
newFocusString += '/' + enum_item_key(*df::global::gametype);
focusStrings.push_back(newFocusString);
}
if (game->main_interface.main_designation_selected != -1) {
newFocusString = baseFocus;
newFocusString += "/Designate/" + enum_item_key(game->main_interface.main_designation_selected);
Expand Down Expand Up @@ -589,7 +583,7 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
focusStrings.push_back(newFocusString);
}

if(game->main_interface.bottom_mode_selected != -1) {
if (game->main_interface.bottom_mode_selected != -1) {
newFocusString = baseFocus;

switch(game->main_interface.bottom_mode_selected) {
Expand Down Expand Up @@ -700,7 +694,7 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
newFocusString += "/ImageCreator";
focusStrings.push_back(newFocusString);
}
if (game->main_interface.unit_selector.flag.bits.WIDGET_VISIBILITY_ACTIVE) {
if (game->main_interface.unit_selector.flag.bits.VISIBILITY_ACTIVE) {
newFocusString = baseFocus;
newFocusString += "/UnitSelector/";
newFocusString += enum_item_key(game->main_interface.unit_selector.context);
Expand All @@ -721,11 +715,6 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
newFocusString += "/PatrolRoutes";
focusStrings.push_back(newFocusString);
}
if (game->main_interface.squad_schedule.open) {
newFocusString = baseFocus;
newFocusString += "/SquadSchedule";
focusStrings.push_back(newFocusString);
}
if (game->main_interface.squad_selector.open) {
newFocusString = baseFocus;
newFocusString += "/SquadSelector";
Expand Down Expand Up @@ -772,6 +761,31 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
newFocusString += "/SquadSupplies";
focusStrings.push_back(newFocusString);
}
if (game->main_interface.squads.open) {
newFocusString = baseFocus;
newFocusString += "/Squads";
if (game->main_interface.squads.editing_squad_schedule_id >= 0) {
newFocusString += "/EditingSchedule";
} else if (game->main_interface.squad_schedule.open) {
newFocusString += "/Schedule";
} else if (game->main_interface.squad_equipment.open) {
newFocusString += "/Equipment";
if (game->main_interface.squad_equipment.customizing_equipment) {
newFocusString += "/Customizing";
if (game->main_interface.squad_equipment.cs_setting_material)
newFocusString += "/Material";
else if (game->main_interface.squad_equipment.cs_setting_color_pattern)
newFocusString += "/Color";
else
newFocusString += "/Default";
}
else
newFocusString += "/Default";
} else {
newFocusString += "/Default";
}
focusStrings.push_back(newFocusString);
}
if (game->main_interface.assign_uniform.open) {
newFocusString = baseFocus;
newFocusString += "/AssignUniform";
Expand Down Expand Up @@ -803,33 +817,33 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)

focusStrings.push_back(newFocusString);
}
if (game->main_interface.squad_equipment.open) {
}

DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
{
std::string newFocusString;

if (df::global::gametype && !World::isFortressMode()) {
newFocusString = baseFocus;
newFocusString += "/SquadEquipment";
if (game->main_interface.squad_equipment.customizing_equipment) {
newFocusString += "/Customizing";
if (game->main_interface.squad_equipment.cs_setting_material)
newFocusString += "/Material";
else if (game->main_interface.squad_equipment.cs_setting_color_pattern)
newFocusString += "/Color";
newFocusString += '/' + enum_item_key(*df::global::gametype);
if (*df::global::gametype == df::game_type::DWARF_ARENA) {
if (game->main_interface.bottom_mode_selected != df::main_bottom_mode_type::NONE)
newFocusString += "/Paint/" + enum_item_key(game->main_interface.bottom_mode_selected);
else if (game->main_interface.arena_unit.open)
newFocusString += "/ConfigureUnit";
else if (game->main_interface.arena_tree.open)
newFocusString += "/ConfigureTree";
else
newFocusString += "/Default";
}
else
newFocusString += "/Default";
focusStrings.push_back(newFocusString);
}
add_main_interface_focus_strings(baseFocus, focusStrings);

if (!focusStrings.size()) {
static const string squads_default = "dwarfmode/Squads/Default";
if (!focusStrings.size() || (focusStrings.size() == 1 && focusStrings[0] == squads_default)) {
focusStrings.push_back(baseFocus + "/Default");
}

// squads panel is not exclusive with the others
if (game->main_interface.squads.open) {
newFocusString = baseFocus;
newFocusString += "/Squads";
focusStrings.push_back(newFocusString);
}
}

/* TODO: understand how this changes for v50
Expand Down
2 changes: 1 addition & 1 deletion library/xml
Submodule xml updated 1 files
+4 −4 df.viewscreen.xml