MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / LoadsaveOpen

Function LoadsaveOpen

src/openrct2-ui/windows/LoadSave.cpp:1161–1205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1159 };
1160
1161 WindowBase* LoadsaveOpen(
1162 LoadSaveAction action, LoadSaveType type, std::string_view defaultPath, LoadSaveCallback callback, bool isJsCallback,
1163 TrackDesign* trackDesign)
1164 {
1165 _trackDesign = trackDesign;
1166 _defaultPath = defaultPath;
1167
1168 auto* windowMgr = GetWindowManager();
1169 auto* w = static_cast<LoadSaveWindow*>(windowMgr->BringToFrontByClass(WindowClass::loadsave));
1170 if (w == nullptr)
1171 {
1172 auto& config = Config::Get().general;
1173 if (config.fileBrowserWidth < kWindowSizeMin.width || config.fileBrowserHeight < kWindowSizeMin.height
1174 || config.fileBrowserWidth > kWindowSizeMax.width || config.fileBrowserHeight > kWindowSizeMax.height)
1175 {
1176 config.fileBrowserWidth = kWindowSize.width;
1177 config.fileBrowserHeight = kWindowSize.height;
1178 Config::Save();
1179 }
1180
1181 ScreenSize windowSize = { config.fileBrowserWidth, config.fileBrowserHeight };
1182
1183 RegisterCallback(callback, isJsCallback);
1184
1185 w = windowMgr->Create<LoadSaveWindow>(
1186 WindowClass::loadsave, windowSize,
1187 { WindowFlag::stickToFront, WindowFlag::resizable, WindowFlag::autoPosition, WindowFlag::centreScreen }, action,
1188 type);
1189 }
1190
1191 bool isSave = action == LoadSaveAction::save;
1192
1193 if (type == LoadSaveType::heightmap && isSave)
1194 {
1195 Guard::Fail("Cannot save images through loadsave window");
1196 }
1197
1198 w->widgets[WIDX_TITLE].text = GetTitleStringId(type, isSave);
1199 if (w->widgets[WIDX_TITLE].text == kStringIdNone)
1200 {
1201 Guard::Fail("Unsupported load/save type: %d", EnumValue(type));
1202 }
1203
1204 return w;
1205 }
1206
1207 void WindowLoadSaveInputKey(WindowBase* w, uint32_t keycode)
1208 {

Callers 2

OpenPreferredFunction · 0.85
showFileBrowseMethod · 0.85

Calls 7

GetWindowManagerFunction · 0.85
SaveFunction · 0.85
RegisterCallbackFunction · 0.85
FailFunction · 0.85
GetTitleStringIdFunction · 0.85
EnumValueFunction · 0.85
BringToFrontByClassMethod · 0.45

Tested by

no test coverage detected