Skip to content

Commit

Permalink
Update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Sep 16, 2020
1 parent 2463c59 commit da943ab
Show file tree
Hide file tree
Showing 39 changed files with 1,380 additions and 967 deletions.
43 changes: 24 additions & 19 deletions CDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

CDebug::CDebug(void dbgCallback(int), int quitParam)
{
dbgWnd =
global::s2->RegisterWindow(std::make_unique<CWindow>(dbgCallback, quitParam, Position(0, 0), Extent(540, 130), "Debugger",
WINDOW_GREEN1, WINDOW_CLOSE | WINDOW_MOVE | WINDOW_MINIMIZE | WINDOW_RESIZE));
dbgWnd = global::s2->RegisterWindow(
std::make_unique<CWindow>(dbgCallback, quitParam, Position(0, 0), Extent(540, 130), "Debugger", WINDOW_GREEN1,
WINDOW_CLOSE | WINDOW_MOVE | WINDOW_MINIMIZE | WINDOW_RESIZE));
dbgWnd->addText("Debugger started", 0, 0, fontsize);
this->dbgCallback_ = dbgCallback;
FrameCounterText = nullptr;
Expand Down Expand Up @@ -123,7 +123,8 @@ void CDebug::actualizeData()
// write new FramesPerSecText and draw it
if(!FramesPerSecText)
FramesPerSecText = dbgWnd->addText("", 0, 20, fontsize);
FramesPerSecText->setText(helpers::format("Frames per Sec: %.2f", tmpFrameCtr / (((float)SDL_GetTicks() - tmpTickCtr) / 1000)));
FramesPerSecText->setText(
helpers::format("Frames per Sec: %.2f", tmpFrameCtr / (((float)SDL_GetTicks() - tmpTickCtr) / 1000)));
// set new values
tmpFrameCtr = 0;
tmpTickCtr = SDL_GetTicks();
Expand All @@ -142,9 +143,11 @@ void CDebug::actualizeData()
// write new MouseText and draw it
const char* clickedStr =
global::s2->Cursor.clicked ?
(global::s2->Cursor.button.left ? "LMB clicked" : (global::s2->Cursor.button.right ? "RMB clicked" : "clicked")) :
(global::s2->Cursor.button.left ? "LMB clicked" :
(global::s2->Cursor.button.right ? "RMB clicked" : "clicked")) :
"unclicked";
MouseText->setText(helpers::format("Mouse: x=%d y=%d %s", global::s2->Cursor.pos.x, global::s2->Cursor.pos.y, clickedStr));
MouseText->setText(
helpers::format("Mouse: x=%d y=%d %s", global::s2->Cursor.pos.x, global::s2->Cursor.pos.y, clickedStr));

// del RegisteredMenusText before drawing new
if(!RegisteredMenusText)
Expand All @@ -167,8 +170,9 @@ void CDebug::actualizeData()
if(!DisplayRectText)
DisplayRectText = dbgWnd->addText("", 0, 90, fontsize);
auto const displayRect = MapObj->getDisplayRect();
DisplayRectText->setText(helpers::format("DisplayRect: (%d,%d)->(%d,%d)\n= size(%d, %d)", displayRect.left, displayRect.top,
displayRect.right, displayRect.bottom, displayRect.getSize().x, displayRect.getSize().y));
DisplayRectText->setText(helpers::format("DisplayRect: (%d,%d)->(%d,%d)\n= size(%d, %d)", displayRect.left,
displayRect.top, displayRect.right, displayRect.bottom,
displayRect.getSize().x, displayRect.getSize().y));

// we will now write the map data if a map is active
MapObj = global::s2->MapObj.get();
Expand All @@ -188,9 +192,10 @@ void CDebug::actualizeData()
MapAuthorText->setText("Author: " + map->getAuthor());
if(!MapTypeText)
MapTypeText = dbgWnd->addText("", 260, 40, fontsize);
const char* ltStr = map->type == MAP_GREENLAND ?
"Greenland" :
(map->type == MAP_WASTELAND ? "Wasteland" : (map->type == MAP_WINTERLAND ? "Winterland" : "Unknown"));
const char* ltStr =
map->type == MAP_GREENLAND ?
"Greenland" :
(map->type == MAP_WASTELAND ? "Wasteland" : (map->type == MAP_WINTERLAND ? "Winterland" : "Unknown"));
MapTypeText->setText(helpers::format("Type: %d (%s)", map->type, ltStr));
if(!MapPlayerText)
MapPlayerText = dbgWnd->addText("", 260, 50, fontsize);
Expand All @@ -200,16 +205,16 @@ void CDebug::actualizeData()
VertexText->setText(helpers::format("Vertex: %d, %d", MapObj->Vertex_.x, MapObj->Vertex_.y));
if(!VertexDataText)
VertexDataText = dbgWnd->addText("", 260, 70, fontsize);
VertexDataText->setText(helpers::format("Vertex Data: x=%d, y=%d, z=%d i=%.2f h=%#04x", vertex.x, vertex.y, vertex.z,
((float)vertex.i) / pow(2, 16), vertex.h));
VertexDataText->setText(helpers::format("Vertex Data: x=%d, y=%d, z=%d i=%.2f h=%#04x", vertex.x, vertex.y,
vertex.z, ((float)vertex.i) / pow(2, 16), vertex.h));
if(!VertexVectorText)
VertexVectorText = dbgWnd->addText("", 260, 80, fontsize);
VertexVectorText->setText(
helpers::format("Vertex Vector: (%.2f, %.2f, %.2f)", vertex.normVector.x, vertex.normVector.y, vertex.normVector.z));
VertexVectorText->setText(helpers::format("Vertex Vector: (%.2f, %.2f, %.2f)", vertex.normVector.x,
vertex.normVector.y, vertex.normVector.z));
if(!FlatVectorText)
FlatVectorText = dbgWnd->addText("", 260, 90, fontsize);
FlatVectorText->setText(
helpers::format("Flat Vector: (%.2f, %.2f, %.2f)", vertex.flatVector.x, vertex.flatVector.y, vertex.flatVector.z));
FlatVectorText->setText(helpers::format("Flat Vector: (%.2f, %.2f, %.2f)", vertex.flatVector.x,
vertex.flatVector.y, vertex.flatVector.z));
if(!rsuTextureText)
rsuTextureText = dbgWnd->addText("", 260, 100, fontsize);
rsuTextureText->setText(helpers::format("RSU-Texture: %#04x", vertex.rsuTexture));
Expand Down Expand Up @@ -251,8 +256,8 @@ void CDebug::actualizeData()
unknown5Text->setText(helpers::format("unknown5: %#04x", vertex.unknown5));
if(!editorModeText)
editorModeText = dbgWnd->addText("", 260, 230, fontsize);
editorModeText->setText(
helpers::format("Editor --> Mode: %d Content: %#04x Content2: %#04x", MapObj->mode, MapObj->modeContent, MapObj->modeContent2));
editorModeText->setText(helpers::format("Editor --> Mode: %d Content: %#04x Content2: %#04x", MapObj->mode,
MapObj->modeContent, MapObj->modeContent2));
} else
{
if(!MapNameText)
Expand Down
9 changes: 6 additions & 3 deletions CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace bfs = boost::filesystem;

//#include <vld.h>

CGame::CGame() : GameResolution(1024, 768), fullscreen(false), Running(true), showLoadScreen(true), lastFps("", 0, 0, FontSize::Medium)
CGame::CGame()
: GameResolution(1024, 768), fullscreen(false), Running(true), showLoadScreen(true),
lastFps("", 0, 0, FontSize::Medium)
{
global::bmpArray.resize(MAXBOBBMP);
global::shadowArray.resize(MAXBOBSHADOW);
Expand Down Expand Up @@ -82,8 +84,9 @@ bool CGame::UnregisterMenu(CMenu* Menu)
CWindow* CGame::RegisterWindow(std::unique_ptr<CWindow> Window)
{
// first find the highest priority
const auto itHighestPriority = std::max_element(
Windows.cbegin(), Windows.cend(), [](const auto& lhs, const auto& rhs) { return lhs->getPriority() < rhs->getPriority(); });
const auto itHighestPriority =
std::max_element(Windows.cbegin(), Windows.cend(),
[](const auto& lhs, const auto& rhs) { return lhs->getPriority() < rhs->getPriority(); });
const int highestPriority = itHighestPriority == Windows.cend() ? 0 : (*itHighestPriority)->getPriority();

for(auto& i : Windows)
Expand Down
43 changes: 27 additions & 16 deletions CGame_Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ void CGame::EventHandling(SDL_Event* Event)
{
case SDL_KEYDOWN:
{
// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and stop
// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and
// stop
// delivering earlier, for doing this we make use of a variable showing us the deliver status
bool delivered = false;
// now we walk through the windows and find out, if cursor is on one of these (ordered by priority)
Expand All @@ -26,7 +27,8 @@ void CGame::EventHandling(SDL_Event* Event)

for(auto& Window : Windows)
{
if(!Window->isWaste() && Window->isMarked() && Window->getPriority() == highestPriority && Window->hasActiveInputElement())
if(!Window->isWaste() && Window->isMarked() && Window->getPriority() == highestPriority
&& Window->hasActiveInputElement())
{
Window->setKeyboardData(Event->key);
delivered = true;
Expand Down Expand Up @@ -140,24 +142,28 @@ void CGame::EventHandling(SDL_Event* Event)
Cursor.pos = Position(Event->motion.x, Event->motion.y);
}
/*
//NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and stop
// delivering earlier, for doing this we make use of a variable showing us the deliver status
int delivered = false;
//NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the
switch and stop
// delivering earlier, for doing this we make use of a variable showing us the deliver
status int delivered = false;
//deliver mouse motion data to the active window
for (int i = 0; i < MAXWINDOWS; i++)
{
if (Windows[i] != nullptr && Windows[i]->isActive() && !Windows[i]->isWaste())
{
Windows[i]->setMouseData(Event->motion);
if ( (Event->motion.x >= Windows[i]->getX()) && (Event->motion.x < Windows[i]->getX() + Windows[i]->getW())
&& (Event->motion.y >= Windows[i]->getY()) && (Event->motion.y < Windows[i]->getY() + Windows[i]->getH()) ) delivered = true;
if ( (Event->motion.x >= Windows[i]->getX()) && (Event->motion.x < Windows[i]->getX() +
Windows[i]->getW())
&& (Event->motion.y >= Windows[i]->getY()) && (Event->motion.y < Windows[i]->getY() + Windows[i]->getH())
) delivered = true;
}
}
if (delivered)
break;
*/

// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and stop
// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and
// stop
// delivering earlier, for doing this we make use of a variable showing us the deliver status
bool delivered = false;
// now we walk through the windows and find out, if cursor is on one of these (ordered by priority)
Expand All @@ -177,7 +183,8 @@ void CGame::EventHandling(SDL_Event* Event)
{
// is the cursor INSIDE the window or does the user move or resize the window?
if(((Event->motion.x >= Window->getX()) && (Event->motion.x < Window->getX() + Window->getW())
&& (Event->motion.y >= Window->getY()) && (Event->motion.y < Window->getY() + Window->getH()))
&& (Event->motion.y >= Window->getY())
&& (Event->motion.y < Window->getY() + Window->getH()))
|| Window->isMoving() || Window->isResizing())
{
// Windows[i]->setActive();
Expand Down Expand Up @@ -235,7 +242,8 @@ void CGame::EventHandling(SDL_Event* Event)
break;
}

// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and stop
// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and
// stop
// delivering earlier, for doing this we make use of a variable showing us the deliver status
bool delivered = false;
// now we walk through the windows and find out, if cursor is on one of these (ordered by priority)
Expand All @@ -255,7 +263,8 @@ void CGame::EventHandling(SDL_Event* Event)
{
// is the cursor INSIDE the window?
if((Event->button.x >= Window->getX()) && (Event->button.x < Window->getX() + Window->getW())
&& (Event->button.y >= Window->getY()) && (Event->button.y < Window->getY() + Window->getH()))
&& (Event->button.y >= Window->getY())
&& (Event->button.y < Window->getY() + Window->getH()))
{
Window->setActive();
Window->setPriority(highestPriority + 1);
Expand Down Expand Up @@ -296,7 +305,8 @@ void CGame::EventHandling(SDL_Event* Event)
// setup mouse cursor data
Cursor.clicked = false;

// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and stop
// NOTE: we will now deliver the data to menus, windows, map etc., sometimes we have to break the switch and
// stop
// delivering earlier, for doing this we make use of a variable showing us the deliver status
bool delivered = false;
// now we walk through the windows and find out, if cursor is on one of these (ordered by priority)
Expand All @@ -316,7 +326,8 @@ void CGame::EventHandling(SDL_Event* Event)
{
// is the cursor INSIDE the window?
if((Event->button.x >= Window->getX()) && (Event->button.x < Window->getX() + Window->getW())
&& (Event->button.y >= Window->getY()) && (Event->button.y < Window->getY() + Window->getH()))
&& (Event->button.y >= Window->getY())
&& (Event->button.y < Window->getY() + Window->getH()))
{
// Windows[i]->setActive();
// Windows[i]->setPriority(highestPriority+1);
Expand All @@ -332,9 +343,9 @@ void CGame::EventHandling(SDL_Event* Event)
break;
}
// if mouse data has been deliverd, stop delivering anymore
/// We can't stop here cause of problems with the map. If user has the left mouse button pressed and modifies the vertices,
/// it will cause a problem if he walks over a window with pressed mouse button and releases it in the window.
/// So the MapObj needs the "release-event" of the mouse button.
/// We can't stop here cause of problems with the map. If user has the left mouse button pressed and
/// modifies the vertices, it will cause a problem if he walks over a window with pressed mouse button and
/// releases it in the window. So the MapObj needs the "release-event" of the mouse button.
// if (delivered)
// break;

Expand Down
32 changes: 19 additions & 13 deletions CGame_Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ bool CGame::ReCreateWindow()
displayTexture_.reset();
renderer_.reset();
window_.reset();
window_.reset(SDL_CreateWindow("Return to the Roots Map editor [BETA]", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
GameResolution.x, GameResolution.y, fullscreen ? SDL_WINDOW_FULLSCREEN : 0));
window_.reset(SDL_CreateWindow("Return to the Roots Map editor [BETA]", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, GameResolution.x, GameResolution.y,
fullscreen ? SDL_WINDOW_FULLSCREEN : 0));
if(!window_)
return false;
renderer_.reset(SDL_CreateRenderer(window_.get(), -1, 0));
if(!renderer_)
return false;
displayTexture_ = makeSdlTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, GameResolution.x, GameResolution.y);
displayTexture_ = makeSdlTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, GameResolution.x,
GameResolution.y);
Surf_Display = makeRGBSurface(GameResolution.x, GameResolution.y, true);
if(!displayTexture_ || !Surf_Display)
return false;
Expand Down Expand Up @@ -75,8 +77,9 @@ bool CGame::Init()
showLoadScreen = true;
// CSurface::Draw(Surf_Display, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface, 0, 0);
auto& surfSplash = global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface;
sge_TexturedRect(Surf_Display.get(), 0, 0, Surf_Display->w - 1, 0, 0, Surf_Display->h - 1, Surf_Display->w - 1, Surf_Display->h - 1,
surfSplash.get(), 0, 0, surfSplash->w - 1, 0, 0, surfSplash->h - 1, surfSplash->w - 1, surfSplash->h - 1);
sge_TexturedRect(Surf_Display.get(), 0, 0, Surf_Display->w - 1, 0, 0, Surf_Display->h - 1, Surf_Display->w - 1,
Surf_Display->h - 1, surfSplash.get(), 0, 0, surfSplash->w - 1, 0, 0, surfSplash->h - 1,
surfSplash->w - 1, surfSplash->h - 1);
RenderPresent();

GameDataLoader gdLoader(global::worldDesc);
Expand All @@ -87,8 +90,9 @@ bool CGame::Init()
}

// continue loading pictures
for(const std::string file : {"GFX/PICS/SETUP000.LBM", "GFX/PICS/SETUP010.LBM", "GFX/PICS/SETUP011.LBM", "GFX/PICS/SETUP012.LBM",
"GFX/PICS/SETUP013.LBM", "GFX/PICS/SETUP014.LBM", "GFX/PICS/SETUP015.LBM"})
for(const std::string file :
{"GFX/PICS/SETUP000.LBM", "GFX/PICS/SETUP010.LBM", "GFX/PICS/SETUP011.LBM", "GFX/PICS/SETUP012.LBM",
"GFX/PICS/SETUP013.LBM", "GFX/PICS/SETUP014.LBM", "GFX/PICS/SETUP015.LBM"})
{
std::cout << "\nLoading file: " << file << "...";
if(!CFile::open_file(global::gameDataFilePath / file, LBM))
Expand All @@ -104,9 +108,10 @@ bool CGame::Init()
}
}

for(const std::string file : {"GFX/PICS/SETUP666.LBM", "GFX/PICS/SETUP667.LBM", "GFX/PICS/SETUP801.LBM", "GFX/PICS/SETUP802.LBM",
"GFX/PICS/SETUP803.LBM", "GFX/PICS/SETUP804.LBM", "GFX/PICS/SETUP805.LBM", "GFX/PICS/SETUP806.LBM",
"GFX/PICS/SETUP810.LBM", "GFX/PICS/SETUP811.LBM", "GFX/PICS/SETUP895.LBM", "GFX/PICS/SETUP896.LBM"})
for(const std::string file :
{"GFX/PICS/SETUP666.LBM", "GFX/PICS/SETUP667.LBM", "GFX/PICS/SETUP801.LBM", "GFX/PICS/SETUP802.LBM",
"GFX/PICS/SETUP803.LBM", "GFX/PICS/SETUP804.LBM", "GFX/PICS/SETUP805.LBM", "GFX/PICS/SETUP806.LBM",
"GFX/PICS/SETUP810.LBM", "GFX/PICS/SETUP811.LBM", "GFX/PICS/SETUP895.LBM", "GFX/PICS/SETUP896.LBM"})
{
std::cout << "\nLoading file: " << file << "...";
if(!CFile::open_file(global::gameDataFilePath / file, LBM))
Expand All @@ -132,7 +137,8 @@ bool CGame::Init()
}
}

for(const std::string file : {"GFX/PICS/SETUP899.LBM", "GFX/PICS/SETUP990.LBM", "GFX/PICS/WORLD.LBM", "GFX/PICS/WORLDMSK.LBM"})
for(const std::string file :
{"GFX/PICS/SETUP899.LBM", "GFX/PICS/SETUP990.LBM", "GFX/PICS/WORLD.LBM", "GFX/PICS/WORLDMSK.LBM"})
{
std::cout << "\nLoading file: " << file << "...";
if(!CFile::open_file(global::gameDataFilePath / file, LBM))
Expand Down Expand Up @@ -215,8 +221,8 @@ bool CGame::Init()
*/

// EVERY MISSION-FILE SHOULD BE LOADED SEPARATLY IF THE SPECIFIED MISSION GOES ON -- SO THIS IS TEMPORARY
for(const std::string file :
{"DATA/MIS0BOBS.LST", "DATA/MIS1BOBS.LST", "DATA/MIS2BOBS.LST", "DATA/MIS3BOBS.LST", "DATA/MIS4BOBS.LST", "DATA/MIS5BOBS.LST"})
for(const std::string file : {"DATA/MIS0BOBS.LST", "DATA/MIS1BOBS.LST", "DATA/MIS2BOBS.LST", "DATA/MIS3BOBS.LST",
"DATA/MIS4BOBS.LST", "DATA/MIS5BOBS.LST"})
{
std::cout << "\nLoading file: " << file << "...";
if(!CFile::open_file(global::gameDataFilePath / file, LST))
Expand Down
Loading

0 comments on commit da943ab

Please sign in to comment.