forked from mirrors/principia
implement DIALOG_ANIMAL for imgui (#199)
Co-authored-by: ROllerozxa <rollerozxa@voxelmanip.se>
This commit is contained in:
parent
565ea8f229
commit
5f71326243
1 changed files with 35 additions and 0 deletions
|
|
@ -233,6 +233,7 @@ namespace UiSave { static void open(); static void layout(); }
|
||||||
namespace UiNewLevel { static void open(); static void layout(); }
|
namespace UiNewLevel { static void open(); static void layout(); }
|
||||||
namespace UiFrequency { static void open(bool is_range, entity *e = G->selection.e); static void layout(); }
|
namespace UiFrequency { static void open(bool is_range, entity *e = G->selection.e); static void layout(); }
|
||||||
namespace UiConfirm { void open(const char* text, const char* button1, principia_action action1, const char* button2, principia_action action2, const char* button3, principia_action action3, struct confirm_data _confirm_data); void layout(); }
|
namespace UiConfirm { void open(const char* text, const char* button1, principia_action action1, const char* button2, principia_action action2, const char* button3, principia_action action3, struct confirm_data _confirm_data); void layout(); }
|
||||||
|
namespace UiAnimal { static void open(); static void layout(); }
|
||||||
|
|
||||||
//On debug builds, open imgui demo window by pressing Shift+F9
|
//On debug builds, open imgui demo window by pressing Shift+F9
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
@ -2734,6 +2735,36 @@ namespace UiConfirm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace UiAnimal {
|
||||||
|
static bool do_open = false;
|
||||||
|
|
||||||
|
static void open() {
|
||||||
|
do_open = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void layout() {
|
||||||
|
handle_do_open(&do_open, "Animal type");
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(200, .0));
|
||||||
|
if (ImGui::BeginPopupModal("Animal type", REF_TRUE, MODAL_FLAGS)) {
|
||||||
|
for (int i = 0; i < NUM_ANIMAL_TYPES; ++i) {
|
||||||
|
if (ImGui::MenuItem(animal_data[i].name)) {
|
||||||
|
entity* e = G->selection.e;
|
||||||
|
|
||||||
|
if (e && e->g_id == O_ANIMAL) {
|
||||||
|
W->add_action(e->id, ACTION_SET_ANIMAL_TYPE, UINT_TO_VOID((uint32_t)i));
|
||||||
|
|
||||||
|
P.add_action(ACTION_HIGHLIGHT_SELECTED, 0);
|
||||||
|
P.add_action(ACTION_RESELECT, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void ui_init() {
|
static void ui_init() {
|
||||||
UiLevelManager::init();
|
UiLevelManager::init();
|
||||||
UiLuaEditor::init();
|
UiLuaEditor::init();
|
||||||
|
|
@ -2763,6 +2794,7 @@ static void ui_layout() {
|
||||||
UiNewLevel::layout();
|
UiNewLevel::layout();
|
||||||
UiFrequency::layout();
|
UiFrequency::layout();
|
||||||
UiConfirm::layout();
|
UiConfirm::layout();
|
||||||
|
UiAnimal::layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
|
//*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
|
||||||
|
|
@ -2932,6 +2964,9 @@ void ui::open_dialog(int num, void *data) {
|
||||||
case DIALOG_LEVEL_INFO:
|
case DIALOG_LEVEL_INFO:
|
||||||
UiMessage::open((char *)data, MessageType::LevelInfo);
|
UiMessage::open((char *)data, MessageType::LevelInfo);
|
||||||
break;
|
break;
|
||||||
|
case DIALOG_ANIMAL:
|
||||||
|
UiAnimal::open();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
tms_errorf("dialog %d not implemented yet", num);
|
tms_errorf("dialog %d not implemented yet", num);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue