Add Play button to map editor
This commit is contained in:
committed by
Matthias Mailänder
parent
0e5ed6a30c
commit
4fc4fb2fb3
@@ -117,6 +117,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
[TranslationReference]
|
[TranslationReference]
|
||||||
const string ExitMapEditorConfirm = "dialog-exit-map-editor.confirm";
|
const string ExitMapEditorConfirm = "dialog-exit-map-editor.confirm";
|
||||||
|
|
||||||
|
[TranslationReference]
|
||||||
|
const string PlayMapWarningTitle = "dialog-play-map-warning.title";
|
||||||
|
|
||||||
|
[TranslationReference]
|
||||||
|
const string PlayMapWarningPrompt = "dialog-play-map-warning.prompt";
|
||||||
|
|
||||||
|
[TranslationReference]
|
||||||
|
const string PlayMapWarningCancel = "dialog-play-map-warning.cancel";
|
||||||
|
|
||||||
readonly Widget menu;
|
readonly Widget menu;
|
||||||
readonly Widget buttonContainer;
|
readonly Widget buttonContainer;
|
||||||
readonly ButtonWidget buttonTemplate;
|
readonly ButtonWidget buttonTemplate;
|
||||||
@@ -153,6 +162,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "SETTINGS", CreateSettingsButton },
|
{ "SETTINGS", CreateSettingsButton },
|
||||||
{ "RESUME", CreateResumeButton },
|
{ "RESUME", CreateResumeButton },
|
||||||
{ "SAVE_MAP", CreateSaveMapButton },
|
{ "SAVE_MAP", CreateSaveMapButton },
|
||||||
|
{ "PLAY_MAP", CreatePlayMapButton },
|
||||||
{ "EXIT_EDITOR", CreateExitEditorButton }
|
{ "EXIT_EDITOR", CreateExitEditorButton }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -478,6 +488,64 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreatePlayMapButton()
|
||||||
|
{
|
||||||
|
if (world.Type != WorldType.Editor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var actionManager = world.WorldActor.Trait<EditorActionManager>();
|
||||||
|
AddButton("PLAY_MAP", "Play Map")
|
||||||
|
.OnClick = () =>
|
||||||
|
{
|
||||||
|
hideMenu = true;
|
||||||
|
var uid = modData.MapCache.GetUpdatedMap(world.Map.Uid);
|
||||||
|
var map = uid == null ? null : modData.MapCache[uid];
|
||||||
|
if (map == null || (map.Visibility != MapVisibility.Lobby && map.Visibility != MapVisibility.MissionSelector))
|
||||||
|
{
|
||||||
|
ConfirmationDialogs.ButtonPrompt(modData,
|
||||||
|
title: PlayMapWarningTitle,
|
||||||
|
text: PlayMapWarningPrompt,
|
||||||
|
onCancel: ShowMenu,
|
||||||
|
cancelText: PlayMapWarningCancel);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExitEditor(actionManager, () =>
|
||||||
|
{
|
||||||
|
Ui.CloseWindow();
|
||||||
|
Ui.ResetTooltips();
|
||||||
|
void CloseMenu()
|
||||||
|
{
|
||||||
|
mpe?.Fade(MenuPaletteEffect.EffectType.None);
|
||||||
|
onExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map.Visibility == MapVisibility.Lobby)
|
||||||
|
{
|
||||||
|
ConnectionLogic.Connect(Game.CreateLocalServer(uid),
|
||||||
|
"",
|
||||||
|
() => Game.OpenWindow("SERVER_LOBBY", new WidgetArgs
|
||||||
|
{
|
||||||
|
{ "onExit", CloseMenu },
|
||||||
|
{ "onStart", () => { } },
|
||||||
|
{ "skirmishMode", true }
|
||||||
|
}),
|
||||||
|
() => Game.CloseServer());
|
||||||
|
}
|
||||||
|
else if (map.Visibility == MapVisibility.MissionSelector)
|
||||||
|
{
|
||||||
|
Game.OpenWindow("MISSIONBROWSER_PANEL", new WidgetArgs
|
||||||
|
{
|
||||||
|
{ "onExit", CloseMenu },
|
||||||
|
{ "onStart", () => { } },
|
||||||
|
{ "initialMap", uid }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void CreateExitEditorButton()
|
void CreateExitEditorButton()
|
||||||
{
|
{
|
||||||
if (world.Type != WorldType.Editor)
|
if (world.Type != WorldType.Editor)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Container@INGAME_MENU:
|
|||||||
Width: WINDOW_RIGHT
|
Width: WINDOW_RIGHT
|
||||||
Height: WINDOW_BOTTOM
|
Height: WINDOW_BOTTOM
|
||||||
Logic: IngameMenuLogic
|
Logic: IngameMenuLogic
|
||||||
Buttons: EXIT_EDITOR, SAVE_MAP, ABORT_MISSION, SURRENDER, RESTART, LOAD_GAME, SAVE_GAME, MUSIC, SETTINGS, RESUME
|
Buttons: EXIT_EDITOR, PLAY_MAP, SAVE_MAP, ABORT_MISSION, SURRENDER, RESTART, LOAD_GAME, SAVE_GAME, MUSIC, SETTINGS, RESUME
|
||||||
ButtonStride: 130, 0
|
ButtonStride: 130, 0
|
||||||
Children:
|
Children:
|
||||||
Image@EVA:
|
Image@EVA:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Container@INGAME_MENU:
|
|||||||
Width: WINDOW_RIGHT
|
Width: WINDOW_RIGHT
|
||||||
Height: WINDOW_BOTTOM
|
Height: WINDOW_BOTTOM
|
||||||
Logic: IngameMenuLogic
|
Logic: IngameMenuLogic
|
||||||
Buttons: RESUME, LOAD_GAME, SAVE_GAME, SETTINGS, MUSIC, SURRENDER, RESTART, ABORT_MISSION, SAVE_MAP, EXIT_EDITOR
|
Buttons: RESUME, LOAD_GAME, SAVE_GAME, SETTINGS, MUSIC, SURRENDER, RESTART, ABORT_MISSION, SAVE_MAP, PLAY_MAP, EXIT_EDITOR
|
||||||
ButtonStride: 0, 40
|
ButtonStride: 0, 40
|
||||||
Children:
|
Children:
|
||||||
Background@BORDER:
|
Background@BORDER:
|
||||||
|
|||||||
@@ -222,6 +222,12 @@ dialog-exit-map-editor =
|
|||||||
.confirm-anyway = Exit anyway
|
.confirm-anyway = Exit anyway
|
||||||
.confirm = Exit
|
.confirm = Exit
|
||||||
|
|
||||||
|
dialog-play-map-warning =
|
||||||
|
.title = Warning
|
||||||
|
.prompt = The map may have been deleted or has
|
||||||
|
errors preventing it from being loaded.
|
||||||
|
.cancel = Okay
|
||||||
|
|
||||||
## IngamePowerBarLogic
|
## IngamePowerBarLogic
|
||||||
## IngamePowerCounterLogic
|
## IngamePowerCounterLogic
|
||||||
label-power-usage = Power Usage: { $usage }/{ $capacity }
|
label-power-usage = Power Usage: { $usage }/{ $capacity }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Container@INGAME_MENU:
|
|||||||
Width: WINDOW_RIGHT
|
Width: WINDOW_RIGHT
|
||||||
Height: WINDOW_BOTTOM
|
Height: WINDOW_BOTTOM
|
||||||
Logic: IngameMenuLogic
|
Logic: IngameMenuLogic
|
||||||
Buttons: RESUME, LOAD_GAME, SAVE_GAME, SETTINGS, MUSIC, SURRENDER, RESTART, ABORT_MISSION, SAVE_MAP, EXIT_EDITOR
|
Buttons: RESUME, LOAD_GAME, SAVE_GAME, SETTINGS, MUSIC, SURRENDER, RESTART, ABORT_MISSION, SAVE_MAP, PLAY_MAP, EXIT_EDITOR
|
||||||
ButtonStride: 0, 40
|
ButtonStride: 0, 40
|
||||||
Children:
|
Children:
|
||||||
Label@VERSION_LABEL:
|
Label@VERSION_LABEL:
|
||||||
|
|||||||
Reference in New Issue
Block a user