more cleanup so that 3D can stay a more permanent thing
This commit is contained in:
parent
30e82851bc
commit
aa99258101
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
extern int depth3d;
|
||||
void EngineProcess();
|
||||
void ClipboardPush(std::string text);
|
||||
std::string ClipboardPull();
|
||||
int GetModifiers();
|
||||
bool LoadWindowPosition(int scale);
|
||||
void SetCursorEnabled(int enabled);
|
@ -21,6 +21,7 @@ void EngineProcess() {}
|
||||
void ClipboardPush(std::string) {}
|
||||
std::string ClipboardPull() { return ""; }
|
||||
int GetModifiers() { return 0; }
|
||||
void SetCursorEnabled(int enabled) {}
|
||||
|
||||
void readFile(std::string filename, std::vector<char> & storage)
|
||||
{
|
||||
|
@ -1,5 +1,3 @@
|
||||
int depth3d = 0;
|
||||
|
||||
#ifdef USE_SDL
|
||||
|
||||
#include <map>
|
||||
@ -49,7 +47,6 @@ extern "C" {
|
||||
|
||||
#include "gui/dialogues/ErrorMessage.h"
|
||||
#include "gui/dialogues/ConfirmPrompt.h"
|
||||
#include "gui/dialogues/InformationMessage.h"
|
||||
#include "gui/interface/Keys.h"
|
||||
#include "gui/Style.h"
|
||||
|
||||
@ -202,7 +199,7 @@ void DrawPixel(pixel * vid, pixel color, int x, int y)
|
||||
if (x >= 0 && x < WINDOWW && y >= 0 && y < WINDOWH)
|
||||
vid[x+y*WINDOWW] = color;
|
||||
}
|
||||
|
||||
// draws a custom cursor, used to make 3D mode work properly (normal cursor ruins the effect)
|
||||
void DrawCursor(pixel * vid)
|
||||
{
|
||||
for (int j = 0; j <= 9; j++)
|
||||
@ -263,8 +260,9 @@ void DrawCursor(pixel * vid)
|
||||
}
|
||||
void blit(pixel * vid)
|
||||
{
|
||||
if(sdl_scrn)
|
||||
if (sdl_scrn)
|
||||
{
|
||||
int depth3d = ui::Engine::Ref().Get3dDepth();
|
||||
if (depth3d)
|
||||
DrawCursor(vid);
|
||||
pixel * src = vid;
|
||||
@ -346,8 +344,9 @@ void blit(pixel * vid)
|
||||
}
|
||||
void blit2(pixel * vid, int currentScale)
|
||||
{
|
||||
if(sdl_scrn)
|
||||
if (sdl_scrn)
|
||||
{
|
||||
int depth3d = ui::Engine::Ref().Get3dDepth();
|
||||
if (depth3d)
|
||||
DrawCursor(vid);
|
||||
pixel * src = vid;
|
||||
@ -499,6 +498,11 @@ SDL_Surface * SDLSetScreen(int newScale, bool newFullscreen)
|
||||
return surface;
|
||||
}
|
||||
|
||||
void SetCursorEnabled(int enabled)
|
||||
{
|
||||
SDL_ShowCursor(enabled);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> readArguments(int argc, char * argv[])
|
||||
{
|
||||
std::map<std::string, std::string> arguments;
|
||||
@ -738,24 +742,6 @@ void DoubleScreenDialog()
|
||||
}
|
||||
}
|
||||
|
||||
void ThreeDeeDialog()
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "We hear your requests, everyone has been asking for a 3D version of TPT. It has long been rejected as 'impossible', but that just isn't true. Many hours of work have been put into finally making a full 3D TPT a reality. ";
|
||||
message << "\nUpon hitting 'Confirm', 3D mode will enable.";
|
||||
if (ConfirmPrompt::Blocking("Enable 3D Mode", message.str()))
|
||||
{
|
||||
depth3d = -3;
|
||||
SDL_ShowCursor(0);
|
||||
new InformationMessage("Success!", "3D Mode enabled!\nYou may disable this at any time in simulation settings for compatibility with 2D saves. I hope you brought your glasses!", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessage::Blocking("Not using 3D Mode", "You make TPT sad");
|
||||
}
|
||||
}
|
||||
|
||||
bool show3dDialog = true;
|
||||
void EngineProcess()
|
||||
{
|
||||
double frameTimeAvg = 0.0f, correctedFrameTimeAvg = 0.0f;
|
||||
@ -813,11 +799,6 @@ void EngineProcess()
|
||||
showDoubleScreenDialog = false;
|
||||
DoubleScreenDialog();
|
||||
}
|
||||
if (show3dDialog)
|
||||
{
|
||||
show3dDialog = false;
|
||||
ThreeDeeDialog();
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
std::cout << "Breaking out of EngineProcess" << std::endl;
|
||||
|
@ -16,6 +16,7 @@ Engine::Engine():
|
||||
FpsLimit(60.0f),
|
||||
Scale(1),
|
||||
Fullscreen(false),
|
||||
Depth3d(0),
|
||||
FrameIndex(0),
|
||||
lastBuffer(NULL),
|
||||
prevBuffers(stack<pixel*>()),
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "common/Singleton.h"
|
||||
#include "graphics/Graphics.h"
|
||||
#include "Window.h"
|
||||
#include "PowderToy.h"
|
||||
|
||||
namespace ui
|
||||
{
|
||||
@ -45,6 +46,8 @@ namespace ui
|
||||
inline bool GetFullscreen() { return Fullscreen; }
|
||||
void SetScale(int scale) { Scale = scale; }
|
||||
inline int GetScale() { return Scale; }
|
||||
void Set3dDepth(int depth3d) { Depth3d = depth3d; if (Depth3d) SetCursorEnabled(0); else SetCursorEnabled(1);}
|
||||
inline int Get3dDepth() { return Depth3d; }
|
||||
void SetFastQuit(bool fastquit) { FastQuit = fastquit; }
|
||||
inline bool GetFastQuit() {return FastQuit; }
|
||||
|
||||
@ -74,6 +77,7 @@ namespace ui
|
||||
Graphics * g;
|
||||
int Scale;
|
||||
bool Fullscreen;
|
||||
int Depth3d;
|
||||
|
||||
unsigned int FrameIndex;
|
||||
private:
|
||||
|
@ -4,15 +4,14 @@
|
||||
OptionsController::OptionsController(GameModel * gModel_, ControllerCallback * callback_):
|
||||
gModel(gModel_),
|
||||
callback(callback_),
|
||||
temp_3ddepth(depth3d),
|
||||
HasExited(false)
|
||||
{
|
||||
this->depth3d = ui::Engine::Ref().Get3dDepth();
|
||||
view = new OptionsView();
|
||||
model = new OptionsModel(gModel);
|
||||
model->AddObserver(view);
|
||||
|
||||
view->AttachController(this);
|
||||
|
||||
}
|
||||
|
||||
void OptionsController::SetHeatSimulation(bool state)
|
||||
@ -84,7 +83,7 @@ void OptionsController::SetFastQuit(bool fastquit)
|
||||
|
||||
void OptionsController::Set3dDepth(int depth)
|
||||
{
|
||||
temp_3ddepth = depth;
|
||||
depth3d = depth;
|
||||
}
|
||||
|
||||
OptionsView * OptionsController::GetView()
|
||||
@ -92,26 +91,14 @@ OptionsView * OptionsController::GetView()
|
||||
return view;
|
||||
}
|
||||
|
||||
#ifdef USE_SDL
|
||||
#ifdef SDL_INC
|
||||
#include "SDL/SDL.h"
|
||||
#else
|
||||
#include "SDL.h"
|
||||
#endif
|
||||
#endif
|
||||
void OptionsController::Exit()
|
||||
{
|
||||
if (ui::Engine::Ref().GetWindow() == view)
|
||||
{
|
||||
ui::Engine::Ref().CloseWindow();
|
||||
}
|
||||
depth3d = temp_3ddepth;
|
||||
#ifdef USE_SDL
|
||||
if (depth3d)
|
||||
SDL_ShowCursor(0);
|
||||
else
|
||||
SDL_ShowCursor(1);
|
||||
#endif
|
||||
// only update on close, it would be hard to edit if the changes were live
|
||||
ui::Engine::Ref().Set3dDepth(depth3d);
|
||||
if (callback)
|
||||
callback->ControllerExit();
|
||||
HasExited = true;
|
||||
|
@ -14,7 +14,7 @@ class OptionsController {
|
||||
OptionsView * view;
|
||||
OptionsModel * model;
|
||||
ControllerCallback * callback;
|
||||
int temp_3ddepth;
|
||||
int depth3d;
|
||||
public:
|
||||
bool HasExited;
|
||||
OptionsController(GameModel * gModel_, ControllerCallback * callback_);
|
||||
|
@ -225,12 +225,12 @@ OptionsView::OptionsView():
|
||||
DepthAction(OptionsView * v_) { v = v_; }
|
||||
virtual void TextChangedCallback(ui::Textbox * sender) { v->c->Set3dDepth(format::StringToNumber<int>(sender->GetText())); }
|
||||
};
|
||||
depthTextbox = new ui::Textbox(ui::Point(8, Size.Y-58), ui::Point(25, 16), format::NumberToString<int>(depth3d));
|
||||
depthTextbox = new ui::Textbox(ui::Point(8, Size.Y-58), ui::Point(25, 16), format::NumberToString<int>(ui::Engine::Ref().Get3dDepth()));
|
||||
depthTextbox->SetInputType(ui::Textbox::Numeric);
|
||||
depthTextbox->SetActionCallback(new DepthAction(this));
|
||||
AddComponent(depthTextbox);
|
||||
|
||||
tempLabel = new ui::Label(ui::Point(depthTextbox->Position.X+depthTextbox->Size.X+3, depthTextbox->Position.Y), ui::Point(Size.X-28, 16), "\bg- Change the depth of the 3d effect");
|
||||
tempLabel = new ui::Label(ui::Point(depthTextbox->Position.X+depthTextbox->Size.X+3, depthTextbox->Position.Y), ui::Point(Size.X-28, 16), "\bg- Change the depth of the 3d glasses effect");
|
||||
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
AddComponent(tempLabel);
|
||||
|
||||
|
@ -2206,10 +2206,13 @@ int LuaScriptInterface::renderer_depth3d(lua_State * l)
|
||||
int acount = lua_gettop(l);
|
||||
if (acount == 0)
|
||||
{
|
||||
lua_pushnumber(l, depth3d);
|
||||
lua_pushnumber(l, ui::Engine::Ref().Get3dDepth());
|
||||
return 1;
|
||||
}
|
||||
depth3d = luaL_optint(l, 1, 2);
|
||||
int depth3d = luaL_optint(l, 1, -3);
|
||||
if (depth3d < -30 || depth3d > 30)
|
||||
return luaL_error(l, "3D depth is too large");
|
||||
ui::Engine::Ref().Set3dDepth(depth3d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user