| 239 | } |
| 240 | |
| 241 | bool init(Asset* asset) |
| 242 | { |
| 243 | TFE_ScriptInterface::registerScriptInterface(API_LEVEL_EDITOR); |
| 244 | TFE_ScriptInterface::setAPI(API_LEVEL_EDITOR, "EditorDef/Scripts"); |
| 245 | |
| 246 | s_levelAsset = asset; |
| 247 | // Initialize editors. |
| 248 | editGeometry_init(); |
| 249 | editGuidelines_init(); |
| 250 | |
| 251 | // Reset output messages. |
| 252 | infoPanelClearMessages(); |
| 253 | infoPanelSetMsgFilter(); |
| 254 | |
| 255 | // Cleanup any existing level data. |
| 256 | destroy(); |
| 257 | edit_clearTextureAppendList(); |
| 258 | |
| 259 | // Load definitions. |
| 260 | // TODO: Handle different games... |
| 261 | const char* gameLocalDir = "DarkForces"; |
| 262 | loadVariableData(gameLocalDir); |
| 263 | loadEntityData(gameLocalDir, false); |
| 264 | loadLogicData(gameLocalDir); |
| 265 | groups_init(); |
| 266 | setTextureAssignDirty(true); |
| 267 | s_viewDepth[0] = c_defaultViewDepth[0]; |
| 268 | s_viewDepth[1] = c_defaultViewDepth[1]; |
| 269 | s_texMoveFeatures.clear(); |
| 270 | s_timeSinceLastUpdate = 0.0; |
| 271 | s_isUiFocused = false; |
| 272 | |
| 273 | Project* project = project_get(); |
| 274 | if (project && project->active) |
| 275 | { |
| 276 | char projEntityDataPath[TFE_MAX_PATH]; |
| 277 | sprintf(projEntityDataPath, "%s/%s.ini", project->path, "CustomEntityDef"); |
| 278 | loadEntityData(projEntityDataPath, true); |
| 279 | } |
| 280 | |
| 281 | browserLoadIcons(); |
| 282 | clearEntityChanges(); |
| 283 | |
| 284 | // Load the new level. |
| 285 | if (!loadLevelFromAsset(asset)) |
| 286 | { |
| 287 | return false; |
| 288 | } |
| 289 | LE_INFO("Loaded level '%s'", s_level.name.c_str()); |
| 290 | |
| 291 | loadPaletteAndColormap(); |
| 292 | |
| 293 | viewport_init(); |
| 294 | |
| 295 | viewport_update((s32)UI_SCALE(480) + 16, (s32)UI_SCALE(68) + 18); |
| 296 | s_gridIndex = 7; |
| 297 | s_grid.size = c_gridSizeMap[s_gridIndex]; |
| 298 | s_timeSinceLastAutosave = 0.0; |
no test coverage detected