game: add an exit button in options

This commit is contained in:
Crypto City 2021-11-17 20:15:05 +00:00
parent da870a1b1c
commit 228bd88685
4 changed files with 16 additions and 0 deletions

View File

@ -14,6 +14,7 @@ TBTabContainer
TBButton: text: "Node"
TBButton: text: "Disk cache"
TBButton: text: "Tutorial"
TBButton: text: "Exit"
TBLayout: axis: y, distribution-position: "left top", distribution: "gravity"
@ -229,3 +230,6 @@ TBTabContainer
TBTextField: text: "Double click on any tutorial to view it:"
TBSelectList: id: "tutorials", gravity: "all"
TBLayout: axis: y, distribution-position: "center", distribution: "gravity"
TBButton: id: "exit", text: "Exit Townforge"

View File

@ -997,6 +997,12 @@ void UIOptionsDialog::HandleShowNotificationHistory(StringHash eventType, Varian
SendEvent(E_OPTIONS_SHOW_NOTIFICATION_HISTORY, newEventData);
}
void UIOptionsDialog::HandleExit(StringHash eventType, VariantMap& eventData)
{
VariantMap newEventData;
SendEvent(E_OPTIONS_EXIT, newEventData);
}
void UIOptionsDialog::HandleEnableTutorial(StringHash eventType, VariantMap& eventData)
{
if (configuring)
@ -1114,6 +1120,7 @@ void UIOptionsDialog::HandleTBMessage(StringHash eventType, VariantMap& eventDat
if (ev->count == 2)
CONNECT("tutorials", HandleShowTutorial);
CONNECT("show-notification-history", HandleShowNotificationHistory);
CONNECT("exit", HandleExit);
}
else if (ev->type == EVENT_TYPE_CHANGED)
{

View File

@ -66,6 +66,7 @@ URHO3D_EVENT(E_OPTIONS_SHOW_NOTIFICATION_HISTORY, OptionsShowNotificationHistory
URHO3D_EVENT(E_OPTIONS_SET_SELECTION_INFO, OptionsSetSelectionInfo) { URHO3D_PARAM(P_ENABLED, Enabled); }
URHO3D_EVENT(E_OPTIONS_TERRAIN_CACHE_SIZE, OptionsTerrainCacheSize) { URHO3D_PARAM(P_SIZE, Size); }
URHO3D_EVENT(E_OPTIONS_VOXEL_LOD, OptionsVoxelLOD) { URHO3D_PARAM(P_LOD, LOD); }
URHO3D_EVENT(E_OPTIONS_EXIT, OptionsExit) { }
class UIOptionsDialog: public UITBWindow
{
@ -121,6 +122,7 @@ private:
void HandleSelectionInfoChanged(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
void HandleTerrainCacheSize(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
void HandleVoxelLOD(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
void HandleExit(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
void HandleTBMessage(Urho3D::StringHash eventType, Urho3D::VariantMap& eventData);
private:

View File

@ -2178,6 +2178,9 @@ void UIUrho3D::ShowOptions()
SubscribeToEvent(optionsDialog, E_OPTIONS_VOXEL_LOD, [this](StringHash eventType, VariantMap& eventData) {
SendEvent(E_CRYPTOCITY_VOXEL_LOD, eventData);
});
SubscribeToEvent(optionsDialog, E_OPTIONS_EXIT, [this](StringHash eventType, VariantMap& eventData) {
OnExitRequest();
});
optionsDialog->Configure();
SendTutorialTrigger("screen-options");
}