1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
// ==============================================================
// This file is part of MegaGlest (www.glest.org)
//
// Copyright (C) 2011 - by Mark Vejvoda <mark_vejvoda@hotmail.com>
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#ifndef _SHADER_G3DVIEWER_MAIN_H_
#define _SHADER_G3DVIEWER_MAIN_H_
#ifdef WIN32
#include <winsock2.h>
#include <winsock.h>
#endif
#include <string>
#include <GL/glew.h>
#include <wx/wx.h>
#include <wx/glcanvas.h>
//#include <wx/clrpicker.h>
#include <wx/colordlg.h>
#include "renderer.h"
#include "util.h"
#include "particle_type.h"
#include "unit_particle_type.h"
using std::string;
using namespace Glest::Game;
namespace Shared{ namespace G3dViewer{
class GlCanvas;
// ===============================
// class MainWindow
// ===============================
class MainWindow: public wxFrame{
private:
DECLARE_EVENT_TABLE()
public:
static const string versionString;
static const string winHeader;
enum MenuId{
miFileLoad,
miFileLoadParticleXML,
miFileLoadProjectileParticleXML,
miFileLoadSplashParticleXML,
miFileClearAll,
miFileToggleScreenshotTransparent,
miFileSaveScreenshot,
miModeWireframe,
miModeNormals,
miModeGrid,
miSpeedSlower,
miSpeedFaster,
miRestart,
miChangeBackgroundColor,
miColorRed,
miColorBlue,
miColorGreen,
miColorYellow,
miColorWhite,
miColorCyan,
miColorOrange,
miColorMagenta
};
private:
GlCanvas *glCanvas;
Renderer *renderer;
wxTimer *timer;
wxMenuBar *menu;
wxMenu *menuFile;
wxMenu *menuMode;
wxMenu *menuSpeed;
wxMenu *menuCustomColor;
wxFileDialog *fileDialog;
wxColourDialog *colorPicker;
Model *model;
std::pair<string,vector<string> > unitPath;
std::vector<string> modelPathList;
std::vector<string> particlePathList;
std::vector<string> particleProjectilePathList;
std::vector<string> particleSplashPathList; // as above
bool resetAnimation;
float resetAnim;
int resetParticleLoopStart;
float speed;
float anim;
float lastanim;
int particleLoopStart;
float rotX, rotY, zoom;
float backBrightness, gridBrightness, lightBrightness;
int lastX, lastY;
Renderer::PlayerColor playerColor;
bool initTextureManager;
std::vector<UnitParticleSystemType *> unitParticleSystemTypes;
std::vector<UnitParticleSystem *> unitParticleSystems;
std::vector<ParticleSystemTypeProjectile *> projectileParticleSystemTypes;
std::vector<ProjectileParticleSystem *> projectileParticleSystems;
std::vector<ParticleSystemTypeSplash *> splashParticleSystemTypes; // as above
std::vector<SplashParticleSystem *> splashParticleSystems;
string statusbarText;
bool isControlKeyPressed;
string appPath;
bool startupSettingsInited;
void loadUnit(string path, string skillName);
void loadModel(string path);
void loadParticle(string path);
void loadProjectileParticle(string path);
void loadSplashParticle(string path);
void saveScreenshot();
public:
MainWindow( std::pair<string,vector<string> > unitToLoad,
const string modelPath,const string particlePath,
const string projectileParticlePath,const string splashParticlePath,
float defaultAnimation,int defaultParticleLoopStart,
float defaultZoom,float defaultXRot, float defaultYRot,
string appPath);
~MainWindow();
void init();
void Notify();
void onPaint(wxPaintEvent &event);
void onClose(wxCloseEvent &event);
void onMenuFileLoad(wxCommandEvent &event);
void onMenuFileLoadParticleXML(wxCommandEvent &event);
void onMenuFileLoadProjectileParticleXML(wxCommandEvent &event);
void onMenuFileLoadSplashParticleXML(wxCommandEvent &event);
void onMenuFileClearAll(wxCommandEvent &event);
void onMenumFileToggleScreenshotTransparent(wxCommandEvent &event);
void onMenuFileSaveScreenshot(wxCommandEvent &event);
void onMenuFileExit(wxCommandEvent &event);
void onMenuModeNormals(wxCommandEvent &event);
void onMenuModeWireframe(wxCommandEvent &event);
void onMenuModeGrid(wxCommandEvent &event);
void onMenuSpeedSlower(wxCommandEvent &event);
void onMenuSpeedFaster(wxCommandEvent &event);
void onMenuRestart(wxCommandEvent &event);
void OnChangeColor(wxCommandEvent &event);
void onMenuColorRed(wxCommandEvent &event);
void onMenuColorBlue(wxCommandEvent &event);
void onMenuColorGreen(wxCommandEvent &event);
void onMenuColorYellow(wxCommandEvent &event);
void onMenuColorWhite(wxCommandEvent &event);
void onMenuColorCyan(wxCommandEvent &event);
void onMenuColorOrange(wxCommandEvent &event);
void onMenuColorMagenta(wxCommandEvent &event);
void onMouseWheelDown(wxMouseEvent &event);
void onMouseWheelUp(wxMouseEvent &event);
void onMouseMove(wxMouseEvent &event);
void onTimer(wxTimerEvent &event);
void onKeyDown(wxKeyEvent &e);
string getModelInfo();
void setupTimer();
void setupStartupSettings();
};
// =====================================================
// class GlCanvas
// =====================================================
class GlCanvas: public wxGLCanvas {
private:
DECLARE_EVENT_TABLE()
public:
GlCanvas(MainWindow *mainWindow, int *args);
~GlCanvas();
void onMouseWheel(wxMouseEvent &event);
void onMouseMove(wxMouseEvent &event);
void onPaint(wxPaintEvent &event);
void onKeyDown(wxKeyEvent &event);
void setCurrentGLContext();
wxGLContext * getCtx() { return context; }
private:
MainWindow *mainWindow;
wxGLContext *context;
};
// ===============================
// class App
// ===============================
class App: public wxApp{
private:
MainWindow *mainWindow;
public:
App() : wxApp() {
mainWindow = NULL;
}
virtual ~App() {}
virtual bool OnInit();
virtual int MainLoop();
virtual int OnExit();
};
}}//end namespace
DECLARE_APP(Shared::G3dViewer::App)
#endif
|