Skip to content

Commit

Permalink
seperate build options for devkeys and debug, and move build opts to …
Browse files Browse the repository at this point in the history
…their own home
  • Loading branch information
robn committed Apr 30, 2011
1 parent f2d735f commit 3735854
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.am
Expand Up @@ -19,7 +19,7 @@ include_HEADERS = Body.h Frame.h glfreetype.h GuiButton.h GuiContainer.h GuiEven
DeleteEmitter.h LuaManager.h LuaUtils.h LuaObject.h LuaEventQueue.h RefList.h RefCounted.h \
LuaBody.h LuaPlanet.h LuaPlayer.h LuaShip.h LuaSpaceStation.h LuaStar.h LuaStarSystem.h LuaSBodyPath.h LuaShipType.h \
LuaSpace.h LuaGame.h LuaUI.h LuaFormat.h LuaTimer.h LuaRand.h LuaEngine.h LuaNameGen.h LuaCargoBody.h LuaEquipType.h \
LuaSBody.h BBAdvertChatForm.h VideoLink.h DeadVideoLink.h FaceVideoLink.h
LuaSBody.h BBAdvertChatForm.h VideoLink.h DeadVideoLink.h FaceVideoLink.h buildopts.h

libgui_a_SOURCES = GuiButton.cpp Gui.cpp GuiFixed.cpp GuiScreen.cpp GuiLabel.cpp GuiToolTip.cpp GuiToggleButton.cpp GuiRadioButton.cpp \
GuiRadioGroup.cpp GuiImageButton.cpp GuiImage.cpp GuiImageRadioButton.cpp GuiMultiStateImageButton.cpp GuiWidget.cpp \
Expand Down
31 changes: 17 additions & 14 deletions src/Pi.cpp
Expand Up @@ -109,7 +109,9 @@ MTRand Pi::rng;
double Pi::gameTime;
float Pi::frameTime;
GLUquadric *Pi::gluQuadric;
#if DEVKEYS
bool Pi::showDebugInfo;
#endif
int Pi::statSceneTris;
bool Pi::isGameStarted = false;
IniConfig Pi::config;
Expand Down Expand Up @@ -536,6 +538,17 @@ void Pi::HandleEvents()
case SDLK_h: // Toggle HDR
Render::ToggleHDR();
break;
case SDLK_PRINT: // print
case SDLK_KP_MULTIPLY: // screen
{
char buf[256];
const time_t t = time(0);
struct tm *_tm = localtime(&t);
strftime(buf, sizeof(buf), "screenshot-%Y%m%d-%H%M%S.tga", _tm);
Screendump(buf);
break;
}
#if DEVKEYS
case SDLK_i: // Toggle Debug info
Pi::showDebugInfo = !Pi::showDebugInfo;
break;
Expand All @@ -549,17 +562,6 @@ void Pi::HandleEvents()
printf("Criminal record now: %llx, $%lld\n", crime, fine);
break;
}
case SDLK_PRINT: // print
case SDLK_KP_MULTIPLY: // screen
{
char buf[256];
const time_t t = time(0);
struct tm *_tm = localtime(&t);
strftime(buf, sizeof(buf), "screenshot-%Y%m%d-%H%M%S.tga", _tm);
Screendump(buf);
break;
}
#ifdef DEBUG
case SDLK_m: // Gimme money!
Pi::player->SetMoney(Pi::player->GetMoney() + 10000000);
break;
Expand Down Expand Up @@ -611,7 +613,7 @@ void Pi::HandleEvents()
}
break;
}
#endif /* DEBUG */
#endif /* DEVKEYS */
#if OBJECTVIEWER
case SDLK_F10:
Pi::SetView(Pi::objectViewerView);
Expand Down Expand Up @@ -1158,14 +1160,15 @@ void Pi::MainLoop()

Render::PostProcess();
Gui::Draw();
//#ifdef DEBUG

#if DEVKEYS
if (Pi::showDebugInfo) {
Gui::Screen::EnterOrtho();
glColor3f(1,1,1);
Gui::Screen::RenderString(fps_readout, 0, 0);
Gui::Screen::LeaveOrtho();
}
//#endif /* DEBUG */
#endif

glError();
Render::SwapBuffers();
Expand Down
2 changes: 2 additions & 0 deletions src/Pi.h
Expand Up @@ -129,7 +129,9 @@ class Pi {
static View *GetView() { return currentView; }
static StarSystem *GetSelectedSystem();

#if DEVKEYS
static bool showDebugInfo;
#endif
static Player *player;
static SectorView *sectorView;
static GalacticView *galacticView;
Expand Down
7 changes: 6 additions & 1 deletion src/WorldView.cpp
Expand Up @@ -99,7 +99,11 @@ WorldView::WorldView(): View()
m_flightStatus = (new Gui::Label(""))->Color(1.0f, 0.7f, 0.0f);
m_rightRegion2->Add(m_flightStatus, 2, 0);

#if DEVKEYS
m_debugInfo = (new Gui::Label(""))->Color(0.8f, 0.8f, 0.8f);
Add(m_debugInfo, 10, 200);
#endif

m_hudVelocity = (new Gui::Label(""))->Color(s_hudTextColor);
m_hudTargetDist = (new Gui::Label(""))->Color(s_hudTextColor);
m_hudAltitude = (new Gui::Label(""))->Color(s_hudTextColor);
Expand All @@ -109,7 +113,6 @@ WorldView::WorldView(): View()
m_hudTargetDist->SetToolTip("Distance from ship to navigation target");
m_hudAltitude->SetToolTip("Ship altitude above terrain");
m_hudPressure->SetToolTip("External atmospheric pressure");
Add(m_debugInfo, 10, 200);
Add(m_hudVelocity, 170.0f, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-66.0f);
Add(m_hudTargetDist, 500.0f, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-66.0f);
Add(m_hudAltitude, 580.0f, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-4.0f);
Expand Down Expand Up @@ -674,6 +677,7 @@ void WorldView::RefreshButtonStateAndVisibility()
m_commsOptions->Hide();
m_commsNavOptionsContainer->Hide();
}
#if DEVKEYS
if (Pi::showDebugInfo) {
char buf[1024];
vector3d pos = Pi::player->GetPosition();
Expand All @@ -692,6 +696,7 @@ void WorldView::RefreshButtonStateAndVisibility()
} else {
m_debugInfo->Hide();
}
#endif

if (const SBodyPath *dest = Space::GetHyperspaceDest()) {
StarSystem *s = StarSystem::GetCached(*dest);
Expand Down
5 changes: 4 additions & 1 deletion src/WorldView.h
Expand Up @@ -81,8 +81,11 @@ class WorldView: public View {
Uint32 m_showTargetActionsTimeout;
Render::Shader *m_bgStarShader;

Gui::Label *m_debugInfo, *m_hudVelocity, *m_hudTargetDist, *m_hudAltitude, *m_hudPressure, *m_hudHyperspaceInfo, *m_hudTargetInfo;
#if DEVKEYS
Gui::Label *m_debugInfo;
#endif

Gui::Label *m_hudVelocity, *m_hudTargetDist, *m_hudAltitude, *m_hudPressure, *m_hudHyperspaceInfo, *m_hudTargetInfo;
Gui::MeterBar *m_hudHullTemp, *m_hudWeaponTemp, *m_hudHullIntegrity, *m_hudShieldIntegrity;
Gui::MeterBar *m_hudTargetHullIntegrity, *m_hudTargetShieldIntegrity;

Expand Down
14 changes: 14 additions & 0 deletions src/buildopts.h
@@ -0,0 +1,14 @@
#ifndef _BUILDOPTS_H
#define _BUILDOPTS_H

// define to include the object viewer in the build
#ifndef OBJECTVIEWER
#define OBJECTVIEWER 1
#endif

// define to include various extra keybindings for dev functions
#ifndef DEVKEYS
#define DEVKEYS 1
#endif

#endif
6 changes: 2 additions & 4 deletions src/libs.h
@@ -1,6 +1,8 @@
#ifndef _LIBS_H
#define _LIBS_H

#include "buildopts.h"

#include <assert.h>
#include <stdio.h>
#include <sigc++/sigc++.h>
Expand All @@ -12,10 +14,6 @@
#include <time.h>
#include <stdarg.h>

// define to include the object viewer in the build
#ifndef OBJECTVIEWER
#define OBJECTVIEWER 1
#endif

/* on unix this would probably become $PREFIX/pioneer */
#ifndef PIONEER_DATA_DIR
Expand Down

0 comments on commit 3735854

Please sign in to comment.