Element sampling HUD thingy (No very good with MVC)
This commit is contained in:
parent
bbfbb81086
commit
c88079d084
@ -348,6 +348,12 @@ void GameController::Tick()
|
||||
|
||||
void GameController::Update()
|
||||
{
|
||||
ui::Point pos = gameView->GetMousePosition();
|
||||
if(pos.X >= 0 && pos.Y >= 0 && pos.X < XRES && pos.Y < YRES)
|
||||
{
|
||||
gameView->SetSample(gameModel->GetSimulation()->Get(pos.X, pos.Y));
|
||||
}
|
||||
|
||||
gameModel->GetSimulation()->update_particles();
|
||||
if(renderOptions && renderOptions->HasExited)
|
||||
{
|
||||
@ -558,4 +564,8 @@ void GameController::ReloadSim()
|
||||
gameModel->GetSimulation()->Load(gameModel->GetSave()->GetData(), gameModel->GetSave()->GetDataLength());
|
||||
}
|
||||
|
||||
std::string GameController::ElementResolve(int type)
|
||||
{
|
||||
return std::string(gameModel->GetSimulation()->ptypes[type].name);
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
void ShowConsole();
|
||||
void FrameStep();
|
||||
ui::Point PointTranslate(ui::Point point);
|
||||
std::string ElementResolve(int type);
|
||||
};
|
||||
|
||||
#endif // GAMECONTROLLER_H
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "Config.h"
|
||||
#include "GameView.h"
|
||||
@ -29,7 +30,8 @@ GameView::GameView():
|
||||
selectPoint1(0, 0),
|
||||
selectPoint2(0, 0),
|
||||
stampThumb(NULL),
|
||||
clipboardThumb(NULL)
|
||||
clipboardThumb(NULL),
|
||||
mousePosition(0, 0)
|
||||
{
|
||||
int currentX = 1;
|
||||
//Set up UI
|
||||
@ -282,6 +284,16 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
|
||||
}
|
||||
}
|
||||
|
||||
void GameView::SetSample(Particle sample)
|
||||
{
|
||||
this->sample = sample;
|
||||
}
|
||||
|
||||
ui::Point GameView::GetMousePosition()
|
||||
{
|
||||
return mousePosition;
|
||||
}
|
||||
|
||||
void GameView::NotifyActiveToolsChanged(GameModel * sender)
|
||||
{
|
||||
for(int i = 0; i < toolButtons.size(); i++)
|
||||
@ -469,6 +481,7 @@ void GameView::NotifyBrushChanged(GameModel * sender)
|
||||
|
||||
void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
||||
{
|
||||
mousePosition = c->PointTranslate(ui::Point(x, y));
|
||||
if(selectMode!=SelectNone)
|
||||
{
|
||||
if(selectMode==PlaceStamp || selectMode==PlaceClipboard)
|
||||
@ -837,9 +850,9 @@ void GameView::changeColour()
|
||||
|
||||
void GameView::OnDraw()
|
||||
{
|
||||
Graphics * g = ui::Engine::Ref().g;
|
||||
if(ren)
|
||||
{
|
||||
Graphics * g = ui::Engine::Ref().g;
|
||||
ren->draw_air();
|
||||
ren->render_parts();
|
||||
ren->render_fire();
|
||||
@ -925,10 +938,19 @@ void GameView::OnDraw()
|
||||
{
|
||||
string message = (*iter);
|
||||
startY -= 13;
|
||||
g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6, 14, 0, 0, 0, 100);
|
||||
g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6 , 14, 0, 0, 0, 100);
|
||||
g->drawtext(startX, startY, message.c_str(), 255, 255, 255, startAlpha);
|
||||
startAlpha-=14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream sampleInfo;
|
||||
sampleInfo.precision(2);
|
||||
if(sample.type)
|
||||
sampleInfo << c->ElementResolve(sample.type) << ", Temp: " << std::fixed << sample.temp -273.15f;
|
||||
else
|
||||
sampleInfo << "Empty";
|
||||
|
||||
g->drawtext(XRES+BARSIZE-(10+Graphics::textwidth((char*)sampleInfo.str().c_str())), 5, (const char*)sampleInfo.str().c_str(), 255, 255, 255, 255);
|
||||
}
|
||||
|
@ -71,12 +71,21 @@ private:
|
||||
ui::Point selectPoint1;
|
||||
ui::Point selectPoint2;
|
||||
|
||||
ui::Point mousePosition;
|
||||
|
||||
Thumbnail * clipboardThumb;
|
||||
Thumbnail * stampThumb;
|
||||
|
||||
Particle sample;
|
||||
|
||||
void changeColour();
|
||||
public:
|
||||
GameView();
|
||||
|
||||
//Breaks MVC, but any other way is going to be more of a mess.
|
||||
ui::Point GetMousePosition();
|
||||
void SetSample(Particle sample);
|
||||
|
||||
void AttachController(GameController * _c){ c = _c; }
|
||||
void NotifyRendererChanged(GameModel * sender);
|
||||
void NotifySimulationChanged(GameModel * sender);
|
||||
|
@ -148,4 +148,6 @@ void Component::OnMouseWheelInside(int localx, int localy, int d)
|
||||
|
||||
Component::~Component()
|
||||
{
|
||||
if(GetParentWindow()->IsFocused(this))
|
||||
GetParentWindow()->FocusComponent(NULL);
|
||||
}
|
||||
|
@ -120,6 +120,15 @@ int Simulation::flood_prop(int x, int y, size_t propoffset, void * propvalue, in
|
||||
return 0;
|
||||
}
|
||||
|
||||
Particle Simulation::Get(int x, int y)
|
||||
{
|
||||
if(pmap[y][x])
|
||||
return parts[pmap[y][x]>>8];
|
||||
if(photons[y][x])
|
||||
return parts[photons[y][x]>>8];
|
||||
return Particle();
|
||||
}
|
||||
|
||||
int Simulation::flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
|
||||
{
|
||||
int c = fullc&0xFF;
|
||||
|
@ -210,6 +210,7 @@ public:
|
||||
int Load(int x, int y, unsigned char * data, int dataLength);
|
||||
unsigned char * Save(int & dataLength);
|
||||
unsigned char * Save(int x1, int y1, int x2, int y2, int & dataLength);
|
||||
Particle Get(int x, int y);
|
||||
inline int is_blocking(int t, int x, int y);
|
||||
inline int is_boundary(int pt, int x, int y);
|
||||
inline int find_next_boundary(int pt, int *x, int *y, int dm, int *em);
|
||||
|
Loading…
Reference in New Issue
Block a user