--- /dev/null
+#include "dynamicdialog.h"
+#include "engineer.h"
+
+DynamicDialog::DynamicDialog(Engineer &e):
+ engineer(e)
+{
+ engineer.add_dynamic_dialog(*this);
+}
+
+DynamicDialog::~DynamicDialog()
+{
+ engineer.remove_dynamic_dialog(*this);
+}
--- /dev/null
+#ifndef DYNAMICDIALOG_H_
+#define DYNAMICDIALOG_H_
+
+#include <msp/gltk/dialog.h>
+
+class Engineer;
+
+class DynamicDialog: public Msp::GLtk::Dialog
+{
+protected:
+ Engineer &engineer;
+
+ DynamicDialog(Engineer &);
+public:
+ virtual ~DynamicDialog();
+
+ virtual void update() = 0;
+};
+
+#endif
#include "3d/track.h"
#include "3d/trackcircuit.h"
#include "3d/vehicle.h"
+#include "dynamicdialog.h"
#include "engineer.h"
#include "mainwindow.h"
#include "newtraindialog.h"
#include "traindialog.h"
-#include "trainview.h"
using namespace std;
using namespace R2C2;
status_timeout = Time::now()+10*Time::sec;
}
-void Engineer::add_train_view(TrainView &tv)
+void Engineer::add_dynamic_dialog(DynamicDialog &tv)
{
- train_views.push_back(&tv);
+ dyn_dialogs.push_back(&tv);
}
-void Engineer::remove_train_view(TrainView &tv)
+void Engineer::remove_dynamic_dialog(DynamicDialog &tv)
{
- train_views.erase(remove(train_views.begin(), train_views.end(), &tv), train_views.end());
+ dyn_dialogs.erase(remove(dyn_dialogs.begin(), dyn_dialogs.end(), &tv), dyn_dialogs.end());
}
int Engineer::main()
layout_3d.tick();
event_disp.tick(Time::zero);
- for(list<TrainView *>::iterator i=train_views.begin(); i!=train_views.end(); ++i)
- (*i)->prepare();
+ for(list<DynamicDialog *>::iterator i=dyn_dialogs.begin(); i!=dyn_dialogs.end(); ++i)
+ (*i)->update();
Time::TimeStamp t = Time::now();
if(status_timeout && t>status_timeout)
#include "options.h"
class MainWindow;
-class TrainView;
+class DynamicDialog;
class Engineer: public Msp::RegisteredApplication<Engineer>
{
MainWindow *main_wnd;
std::list<R2C2::Train *> new_trains;
- std::list<TrainView *> train_views;
+ std::list<DynamicDialog *> dyn_dialogs;
Msp::Time::TimeStamp status_timeout;
R2C2::Vector pointer;
std::list<R2C2::TrackChain3D *> emergencies;
R2C2::Layout3D &get_layout_3d() { return layout_3d; }
R2C2::View3D &get_main_view() { return main_view; }
void set_status(const std::string &);
- void add_train_view(TrainView &);
- void remove_train_view(TrainView &);
+ void add_dynamic_dialog(DynamicDialog &);
+ void remove_dynamic_dialog(DynamicDialog &);
int main();
void quit() { exit(0); }
private:
using namespace R2C2;
TrainView::TrainView(Engineer &e, const Train &t):
- engineer(e),
+ DynamicDialog(e),
train(t),
mode(SIDE),
forward(true),
view.get_camera().set_depth_clip(0.01, 10);
dynamic_cast<GLtk::Image *>(get_item(widgets, "img_view"))->set_image(&tex);
-
- engineer.add_train_view(*this);
-}
-
-TrainView::~TrainView()
-{
- engineer.remove_train_view(*this);
}
void TrainView::set_mode(Mode m)
forward = f;
}
-void TrainView::prepare()
+void TrainView::update()
{
const Vehicle &veh = train.get_vehicle(0);
const Vector &pos = veh.get_position();
#include <msp/gl/renderbuffer.h>
#include <msp/gl/framebuffer.h>
#include <msp/gl/texture2d.h>
-#include <msp/gltk/dialog.h>
#include <msp/gltk/toggle.h>
#include "libr2c2/train.h"
+#include "dynamicdialog.h"
-class Engineer;
-
-class TrainView: public Msp::GLtk::Dialog
+class TrainView: public DynamicDialog
{
public:
enum Mode
};
private:
- Engineer &engineer;
const R2C2::Train &train;
Msp::GLtk::Toggle *tgl_forward;
Mode mode;
public:
TrainView(Engineer &, const R2C2::Train &);
- ~TrainView();
void set_mode(Mode);
private:
void ui_mode_toggled(bool, Mode);
public:
void set_forward(bool);
- void prepare();
+ virtual void update();
};
#endif