Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 0 additions & 200 deletions callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,206 +1171,6 @@ void callback::EditorTextureMenu(int Param)
lastContent = MapObj->getModeContent();
}

void callback::EditorTreeMenu(int Param)
{
static CWindow* WNDTree = nullptr;
static CMap* MapObj = nullptr;
static bobMAP* map = nullptr;
static int lastContent = 0x00;
static int lastContent2 = 0x00;
static Position Pos{230, 0};

enum
{
WINDOWQUIT,
PICPINE,
PICBIRCH,
PICOAK,
PICPALM1,
PICPALM2,
PICPINEAPPLE,
PICCYPRESS,
PICCHERRY,
PICFIR,
PICSPIDER,
PICFLAPHAT,
PICWOOD_MIXED,
PICPALM_MIXED
};

if(Param != INITIALIZING_CALL && Param != MAP_QUIT)
assert(WNDTree && MapObj && map);

switch(Param)
{
case INITIALIZING_CALL:
if(WNDTree)
break;
WNDTree = global::s2->RegisterWindow(
std::make_unique<CWindow>(EditorTreeMenu, WINDOWQUIT, Pos, Extent(148, 140), "Trees", WINDOW_GREEN1,
WINDOW_CLOSE | WINDOW_MINIMIZE | WINDOW_MOVE));
MapObj = global::s2->getMapObj();
map = MapObj->getMap();
switch(map->type)
{
case MAP_GREENLAND:
WNDTree->addPicture(EditorTreeMenu, PICPINE, Position(2, 2), PICTURE_TREE_PINE);
WNDTree->addPicture(EditorTreeMenu, PICBIRCH, Position(36, 2), PICTURE_TREE_BIRCH);
WNDTree->addPicture(EditorTreeMenu, PICOAK, Position(70, 2), PICTURE_TREE_OAK);
WNDTree->addPicture(EditorTreeMenu, PICPALM1, Position(104, 2), PICTURE_TREE_PALM1);
WNDTree->addPicture(EditorTreeMenu, PICPALM2, Position(2, 36), PICTURE_TREE_PALM2);
WNDTree->addPicture(EditorTreeMenu, PICPINEAPPLE, Position(36, 36), PICTURE_TREE_PINEAPPLE);
WNDTree->addPicture(EditorTreeMenu, PICCYPRESS, Position(70, 36), PICTURE_TREE_CYPRESS);
WNDTree->addPicture(EditorTreeMenu, PICCHERRY, Position(104, 36), PICTURE_TREE_CHERRY);
WNDTree->addPicture(EditorTreeMenu, PICFIR, Position(2, 72), PICTURE_TREE_FIR);
WNDTree->addPicture(EditorTreeMenu, PICWOOD_MIXED, Position(36, 70), PICTURE_TREE_WOOD_MIXED);
WNDTree->addPicture(EditorTreeMenu, PICPALM_MIXED, Position(70, 70), PICTURE_TREE_PALM_MIXED);
break;
case MAP_WASTELAND:
WNDTree->addPicture(EditorTreeMenu, PICFLAPHAT, Position(2, 2), PICTURE_TREE_FLAPHAT);
WNDTree->addPicture(EditorTreeMenu, PICSPIDER, Position(36, 2), PICTURE_TREE_SPIDER);
WNDTree->addPicture(EditorTreeMenu, PICPINEAPPLE, Position(70, 2), PICTURE_TREE_PINEAPPLE);
WNDTree->addPicture(EditorTreeMenu, PICCHERRY, Position(104, 2), PICTURE_TREE_CHERRY);
break;
case MAP_WINTERLAND:
WNDTree->addPicture(EditorTreeMenu, PICPINE, Position(2, 2), PICTURE_TREE_PINE);
WNDTree->addPicture(EditorTreeMenu, PICBIRCH, Position(36, 2), PICTURE_TREE_BIRCH);
WNDTree->addPicture(EditorTreeMenu, PICCYPRESS, Position(70, 2), PICTURE_TREE_CYPRESS);
WNDTree->addPicture(EditorTreeMenu, PICFIR, Position(104, 2), PICTURE_TREE_FIR);
WNDTree->addPicture(EditorTreeMenu, PICWOOD_MIXED, Position(2, 36), PICTURE_TREE_WOOD_MIXED);
break;
default: // should not happen
break;
}
MapObj->setMode(EDITOR_MODE_TREE);
MapObj->setModeContent(0x30);
MapObj->setModeContent2(0xC4);
lastContent = 0x30;
lastContent2 = 0xC4;
break;

case PICPINE:
MapObj->setModeContent(0x30);
MapObj->setModeContent2(0xC4);
lastContent = 0x30;
lastContent2 = 0xC4;
break;
case PICBIRCH:
MapObj->setModeContent(0x70);
MapObj->setModeContent2(0xC4);
lastContent = 0x70;
lastContent2 = 0xC4;
break;
case PICOAK:
MapObj->setModeContent(0xB0);
MapObj->setModeContent2(0xC4);
lastContent = 0xB0;
lastContent2 = 0xC4;
break;
case PICPALM1:
MapObj->setModeContent(0xF0);
MapObj->setModeContent2(0xC4);
lastContent = 0xF0;
lastContent2 = 0xC4;
break;
case PICPALM2:
MapObj->setModeContent(0x30);
MapObj->setModeContent2(0xC5);
lastContent = 0x30;
lastContent2 = 0xC5;
break;
case PICPINEAPPLE:
MapObj->setModeContent(0x70);
MapObj->setModeContent2(0xC5);
lastContent = 0x70;
lastContent2 = 0xC5;
break;
case PICCYPRESS:
MapObj->setModeContent(0xB0);
MapObj->setModeContent2(0xC5);
lastContent = 0xB0;
lastContent2 = 0xC5;
break;
case PICCHERRY:
MapObj->setModeContent(0xF0);
MapObj->setModeContent2(0xC5);
lastContent = 0xF0;
lastContent2 = 0xC5;
break;
case PICFIR:
MapObj->setModeContent(0x30);
MapObj->setModeContent2(0xC6);
lastContent = 0x30;
lastContent2 = 0xC6;
break;
case PICFLAPHAT:
MapObj->setModeContent(0x70);
MapObj->setModeContent2(0xC4);
lastContent = 0x70;
lastContent2 = 0xC4;
break;
case PICSPIDER:
MapObj->setModeContent(0x30);
MapObj->setModeContent2(0xC4);
lastContent = 0x30;
lastContent2 = 0xC4;
break;
case PICWOOD_MIXED:
MapObj->setModeContent(0xFF);
MapObj->setModeContent2(0xC4);
lastContent = 0xFF;
lastContent2 = 0xC4;
break;
case PICPALM_MIXED:
MapObj->setModeContent(0xFF);
MapObj->setModeContent2(0xC5);
lastContent = 0xFF;
lastContent2 = 0xC5;
break;

case WINDOW_CLICKED_CALL:
if(MapObj)
{
MapObj->setMode(EDITOR_MODE_TREE);
MapObj->setModeContent(lastContent);
MapObj->setModeContent2(lastContent2);
}
break;

case WINDOWQUIT:
if(WNDTree)
{
Pos = WNDTree->getPos();
WNDTree->setWaste();
WNDTree = nullptr;
}
MapObj->setMode(EDITOR_MODE_HEIGHT_RAISE);
MapObj->setModeContent(0x00);
MapObj->setModeContent2(0x00);
lastContent = 0x00;
lastContent2 = 0x00;
MapObj = nullptr;
map = nullptr;
break;

case MAP_QUIT:
// we do the same like in case WINDOWQUIT, but we won't setMode(EDITOR_MODE_HEIGHT_RAISE), cause map is dead
if(WNDTree)
{
Pos = WNDTree->getPos();
WNDTree->setWaste();
WNDTree = nullptr;
}
lastContent = 0x00;
lastContent2 = 0x00;
MapObj = nullptr;
map = nullptr;
break;

default: break;
}
}

void callback::EditorResourceMenu(int Param)
{
static CWindow* WNDResource = nullptr;
Expand Down
7 changes: 4 additions & 3 deletions callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include "iwTree.h"

// NOTE: negative callbackParams are reserved: -1 = callback is called first time, -2 = used by gameloop for registered
// callbacks (callbacks that will additionally execute WITHIN the gameloop)

// NOTE: don't forget that if the map quits (Param: MAP_QUIT), there are many windows that have to be closed.
// This happens for example if a new Map will be loaded or user goes to main menu. So if you add a new window, don't
// forget to add it to this "close lists" if it's necessary (also in the file CMap.cpp, function setMouseData(Button)).

#pragma once

namespace callback {
// PleaseWait creates a small window (not moveable, not resizeable, not minimizable, not closeable) with the String
// "Please wait..."
Expand All @@ -26,7 +28,6 @@ void EditorLoadMenu(int Param);
void EditorSaveMenu(int Param);
void EditorQuitMenu(int Param);
void EditorTextureMenu(int Param);
void EditorTreeMenu(int Param);
void EditorResourceMenu(int Param);
void EditorLandscapeMenu(int Param);
void EditorAnimalMenu(int Param);
Expand Down
Loading