Skip to content

Commit

Permalink
Add ship name and class to intro screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraven committed Feb 7, 2019
1 parent d0da7d8 commit 9e71398
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
14 changes: 14 additions & 0 deletions data/pigui/mainmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ local function showMainMenu()
ui.withFont("orbiteer",36 * (ui.screenHeight/1200),function() ui.text("Pioneer") end)
end)
end)
ui.setNextWindowPos(Vector(ui.screenWidth / 4.2,ui.screenHeight / 5.0 * 4),'Always')
ui.withStyleColors({["WindowBg"]=colors.transparent}, function()
ui.window("shipinfoWindow", {"NoTitleBar","NoResize","NoFocusOnAppearing","NoBringToFrontOnFocus","AlwaysAutoResize"}, function()
ui.withFont("orbiteer",30 * (ui.screenHeight/1200),function()
local mn = Engine.GetIntroCurrentModelName()
if mn then
local sd = ShipDef[mn]
if sd then
ui.text(sd.name .. " - " .. lui[sd.shipClass:upper()])
end
end
end)
end)
end)
local build_text = Engine.version
ui.withFont("orbiteer", 16 * (ui.screenHeight/1200),
function()
Expand Down
2 changes: 1 addition & 1 deletion src/Intro.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Intro : public Cutscene {
Intro(Graphics::Renderer *r, int width, int height);
~Intro();
virtual void Draw(float time);

SceneGraph::Model *getCurrentModel() const { if(m_modelIndex >= 0 && m_modelIndex < m_models.size()) return m_models[m_modelIndex]; else return nullptr; }
private:
void Reset(float time);
bool m_needReset;
Expand Down
20 changes: 20 additions & 0 deletions src/LuaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "FloatComparison.h"
#include "Game.h"
#include "GameConfig.h"
#include "Intro.h"
#include "KeyBindings.h"
#include "Lang.h"
#include "LuaConstants.h"
Expand Down Expand Up @@ -695,6 +696,23 @@ static int l_engine_set_gpu_jobs_enabled(lua_State *l)
return 0;
}

static int l_engine_get_intro_current_model_name(lua_State *l)
{
if(Pi::intro) {
SceneGraph::Model *m = Pi::intro->getCurrentModel();
if(m) {
LuaPush(l, m->GetName());
return 1;
} else {
lua_pushnil(l);
return 1;
}
} else {
lua_pushnil(l);
return 1;
}
}

/*
* Method: ShipSpaceToScreenSpace
*
Expand Down Expand Up @@ -1160,6 +1178,8 @@ void LuaEngine::Register()

{ "GetModel", l_engine_get_model },

{ "GetIntroCurrentModelName", l_engine_get_intro_current_model_name },

{ "GetSectorMapZoomLevel", l_engine_get_sector_map_zoom_level },
{ "SectorMapZoomIn", l_engine_sector_map_zoom_in },
{ "SectorMapZoomOut", l_engine_sector_map_zoom_out },
Expand Down

0 comments on commit 9e71398

Please sign in to comment.