| 1 |
#include "MissionInfoGuiView.h" |
| 2 |
|
| 3 |
#include "math/Vector4.h" |
| 4 |
|
| 5 |
namespace ui |
| 6 |
{ |
| 7 |
|
| 8 |
MissionInfoGuiView::MissionInfoGuiView(wxWindow* parent) : |
| 9 |
GuiView(parent) |
| 10 |
{} |
| 11 |
|
| 12 |
void MissionInfoGuiView::setGLViewPort() |
| 13 |
{ |
| 14 |
double width = _windowDims[0]; |
| 15 |
double height = _windowDims[1]; |
| 16 |
|
| 17 |
double aspectRatio = _bgDims[0] / _bgDims[1]; |
| 18 |
|
| 19 |
if (width / height > aspectRatio) |
| 20 |
{ |
| 21 |
width = height * aspectRatio; |
| 22 |
} |
| 23 |
else |
| 24 |
{ |
| 25 |
height = width / aspectRatio; |
| 26 |
} |
| 27 |
|
| 28 |
glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height)); |
| 29 |
} |
| 30 |
|
| 31 |
void MissionInfoGuiView::setGui(const gui::IGuiPtr& gui) |
| 32 |
{ |
| 33 |
// Call the base class first |
| 34 |
GuiView::setGui(gui); |
| 35 |
|
| 36 |
Vector2 topLeft(0, 0); |
| 37 |
Vector2 bottomRight(640, 480); |
| 38 |
|
| 39 |
if (_gui != NULL) |
| 40 |
{ |
| 41 |
gui::IGuiWindowDefPtr bgWindowDef = _gui->findWindowDef(getTargetWindowDefName()); |
| 42 |
|
| 43 |
if (bgWindowDef) |
| 44 |
{ |
| 45 |
const Vector4& rect = bgWindowDef->rect; |
| 46 |
topLeft = Vector2(rect[0], rect[1]); |
| 47 |
bottomRight = Vector2(rect[0] + rect[2], rect[1] + rect[3]); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
_bgDims = bottomRight - topLeft; |
| 52 |
|
| 53 |
_renderer.setVisibleArea(topLeft, bottomRight); |
| 54 |
|
| 55 |
// Only draw a certain windowDef |
| 56 |
setWindowDefFilter(getTargetWindowDefName()); |
| 57 |
} |
| 58 |
|
| 59 |
// ---------- Darkmod.xt ---------------- |
| 60 |
|
| 61 |
DarkmodTxtGuiView::DarkmodTxtGuiView(wxWindow* parent) : |
| 62 |
MissionInfoGuiView(parent) |
| 63 |
{} |
| 64 |
|
| 65 |
void DarkmodTxtGuiView::setMissionInfoFile(const map::DarkmodTxtPtr& file) |
| 66 |
{ |
| 67 |
_file = file; |
| 68 |
} |
| 69 |
|
| 70 |
void DarkmodTxtGuiView::updateGuiState() |
| 71 |
{ |
| 72 |
const gui::IGuiPtr& gui = getGui(); |
| 73 |
|
| 74 |
if (!_file || !gui) return; |
| 75 |
|
| 76 |
// This is a localised value, hardcode some for the moment being |
| 77 |
gui->setStateString("details_posx", "100"); |
| 78 |
|
| 79 |
gui->findWindowDef("modTitle")->text.setValue(_file->getTitle()); |
| 80 |
gui->findWindowDef("modDescription")->text.setValue(_file->getDescription()); |
| 81 |
gui->findWindowDef("modAuthor")->text.setValue(_file->getAuthor()); |
| 82 |
|
| 83 |
// These are internationalised strings in the GUI code, let's hardcode some for the preview |
| 84 |
gui->findWindowDef("modLastPlayedTitle")->text.setValue("Last played:"); |
| 85 |
gui->findWindowDef("modCompletedTitle")->text.setValue("Completed:"); |
| 86 |
gui->findWindowDef("modLastPlayedValue")->text.setValue("2017-11-19"); |
| 87 |
gui->findWindowDef("modCompletedValue")->text.setValue("2017-11-26"); |
| 88 |
gui->findWindowDef("modSizeTitle")->text.setValue("Space used:"); |
| 89 |
gui->findWindowDef("modSizeValue")->text.setValue("123 MB"); |
| 90 |
|
| 91 |
if (gui->findWindowDef("modSizeEraseFromDiskAction")) |
| 92 |
{ |
| 93 |
gui->findWindowDef("modSizeEraseFromDiskAction")->text.setValue("[Erase from disk]"); |
| 94 |
} |
| 95 |
|
| 96 |
gui->findWindowDef("modLoadN")->text.setValue("Install Mission"); |
| 97 |
gui->findWindowDef("modLoadH")->text.setValue("Install Mission"); |
| 98 |
gui->findWindowDef("modLoad")->text.setValue("Install Mission"); |
| 99 |
gui->findWindowDef("moreInfoH")->text.setValue("Notes"); |
| 100 |
gui->findWindowDef("moreInfoN")->text.setValue("Notes"); |
| 101 |
gui->findWindowDef("moreInfo")->text.setValue("Notes"); |
| 102 |
|
| 103 |
redraw(); |
| 104 |
} |
| 105 |
|
| 106 |
std::string DarkmodTxtGuiView::getTargetWindowDefName() |
| 107 |
{ |
| 108 |
return "ModToInstallParent"; |
| 109 |
} |
| 110 |
|
| 111 |
// ---------- Readme.xt ---------------- |
| 112 |
|
| 113 |
ReadmeTxtGuiView::ReadmeTxtGuiView(wxWindow* parent) : |
| 114 |
MissionInfoGuiView(parent) |
| 115 |
{} |
| 116 |
|
| 117 |
void ReadmeTxtGuiView::setMissionInfoFile(const map::ReadmeTxtPtr& file) |
| 118 |
{ |
| 119 |
_file = file; |
| 120 |
} |
| 121 |
|
| 122 |
void ReadmeTxtGuiView::updateGuiState() |
| 123 |
{ |
| 124 |
const gui::IGuiPtr& gui = getGui(); |
| 125 |
|
| 126 |
if (!_file || !gui) return; |
| 127 |
|
| 128 |
gui->setStateString("ModNotesText", _file->getContents()); |
| 129 |
gui->findWindowDef("ModInstallationNotesButtonOK")->text.setValue("OK"); |
| 130 |
|
| 131 |
redraw(); |
| 132 |
} |
| 133 |
|
| 134 |
std::string ReadmeTxtGuiView::getTargetWindowDefName() |
| 135 |
{ |
| 136 |
return "ModInstallationNotesParchment"; |
| 137 |
} |
| 138 |
|
| 139 |
} // namespace |