mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 11:42:31 +01:00
more fixes for editor
This commit is contained in:
parent
81683509d9
commit
f545edad68
@ -1,4 +1,5 @@
|
||||
; === propertyMap File ===
|
||||
|
||||
AiLog=0
|
||||
AiRedir=false
|
||||
AllowDownloadDataSynch=false
|
||||
@ -15,8 +16,8 @@ ConsoleTimeout=20
|
||||
DayTime=1000
|
||||
DebugLogFile=debug.log
|
||||
DebugMode=false
|
||||
DebugPerformance=false
|
||||
DebugNetwork=false
|
||||
DebugPerformance=false
|
||||
DebugWorldSynch=false
|
||||
DepthBits=16
|
||||
FactoryGraphics=OpenGL
|
||||
@ -44,17 +45,17 @@ FontMenuNormalPrefix=-*-helvetica-*-r-*-*-
|
||||
FontMenuVeryBigBaseSize=25
|
||||
FontSizeAdjustment=0
|
||||
Lang=english
|
||||
MaxLights=3
|
||||
;Masterserver=http://soft-haus.com/glest/cgi-bin/
|
||||
;MasterServerExternalPortList=80,143,587,21,110,25,443,993,995
|
||||
Masterserver=http://megaglest.pepper.freeit.org/masterserver/
|
||||
MapPreview=1
|
||||
MasterServerExternalPort=61357
|
||||
MasterServerExternalPortList=61357,61358,61359,61360,61000,80,143,587,21,110,25,443,993,995,1080,8080
|
||||
Masterserver=http://megaglest.pepper.freeit.org/masterserver/
|
||||
MaxLights=3
|
||||
NetPlayerName=newbie
|
||||
NetworkConsistencyChecks=true
|
||||
PhotoMode=false
|
||||
RefreshFrequency=75
|
||||
ScreenHeight=768
|
||||
ScreenWidth=1024
|
||||
ScreenHeight=1200
|
||||
ScreenWidth=1600
|
||||
ServerIp=192.168.0.107
|
||||
ServerPort=61357
|
||||
ShadowAlpha=0.2
|
||||
@ -65,9 +66,9 @@ SoundStaticBuffers=16
|
||||
SoundStreamingBuffers=4
|
||||
SoundVolumeAmbient=80
|
||||
SoundVolumeFx=80
|
||||
SoundVolumeMusic=90
|
||||
SoundVolumeMusic=10
|
||||
StencilBits=0
|
||||
Textures3D=true
|
||||
UnitParticles=true
|
||||
Textures3D=1
|
||||
UnitParticles=1
|
||||
UserData_Root=mydata/
|
||||
Windowed=false
|
||||
Windowed=0
|
||||
|
@ -99,7 +99,7 @@ MainWindow::MainWindow(const string &modelPath)
|
||||
menuSpeed->Append(miSpeedSlower, wxT("&Slower\t-"));
|
||||
menuSpeed->Append(miSpeedFaster, wxT("&Faster\t+"));
|
||||
menuSpeed->AppendSeparator();
|
||||
menuSpeed->Append(miRestart, wxT("&Restart particles\tR"));
|
||||
menuSpeed->Append(miRestart, wxT("&Restart particles\tR"), wxT("Restart particle animations, this also reloads model and particle files if they are changed"));
|
||||
menu->Append(menuSpeed, wxT("&Speed"));
|
||||
|
||||
//custom color
|
||||
@ -974,7 +974,8 @@ bool App::OnInit(){
|
||||
std::cout << "glest_g3dviewer [G3D 3D-MODEL FILE]" << std::endl << std::endl;
|
||||
std::cout << "Displays glest 3D-models and unit/projectile/splash particle systems." << std::endl;
|
||||
std::cout << "rotate with left mouse button, zoom with right mouse button or mousewheel." << std::endl;
|
||||
std::cout << "Use ctrl to load more than one particle system. Press R to restart particles." << std::endl << std::endl;
|
||||
std::cout << "Use ctrl to load more than one particle system." << std::endl;
|
||||
std::cout << "Press R to restart particles, this also reloads all files if they are changed." << std::endl << std::endl;
|
||||
exit (0);
|
||||
}
|
||||
modelPath= wxFNCONV(argv[1]);
|
||||
|
@ -949,13 +949,13 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
|
||||
// white shadowed is default ( in the menu for example )
|
||||
fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
renderTextShadow(
|
||||
text,
|
||||
CoreData::getInstance().getConsoleFont(),
|
||||
fontColor,
|
||||
300, 150);
|
||||
|
||||
|
||||
//textRenderer->begin(CoreData::getInstance().getConsoleFont());
|
||||
//textRenderer->render(text, 300, 150);
|
||||
//textRenderer->end();
|
||||
@ -3172,20 +3172,20 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
|
||||
glPushAttrib(GL_ENABLE_BIT| GL_TEXTURE_BIT);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glAlphaFunc(GL_GREATER, 0.4f);
|
||||
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
|
||||
//set color to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
||||
|
||||
|
||||
//set alpha to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||
}
|
||||
|
||||
|
||||
modelRenderer->begin(false, renderingShadows, false);
|
||||
glInitNames();
|
||||
}
|
||||
@ -3236,26 +3236,26 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
|
||||
modelRenderStarted = true;
|
||||
glPushAttrib(GL_ENABLE_BIT| GL_TEXTURE_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
||||
if (!renderingShadows) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
} else {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glAlphaFunc(GL_GREATER, 0.4f);
|
||||
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
|
||||
//set color to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
||||
|
||||
|
||||
//set alpha to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||
}
|
||||
|
||||
|
||||
modelRenderer->begin(false, renderingShadows, false);
|
||||
|
||||
glInitNames();
|
||||
@ -4119,7 +4119,7 @@ VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame,
|
||||
return quadCache;
|
||||
}
|
||||
|
||||
void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
||||
void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
||||
int screenPosX, int screenPosY,
|
||||
Texture2D **renderToTexture) {
|
||||
float alt=0;
|
||||
@ -4130,7 +4130,7 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
||||
float playerCrossSize=2;
|
||||
float clientW=renderMapWidth*cellSize;
|
||||
float clientH=renderMapHeight*cellSize;;
|
||||
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
// stretch small maps to 128x128
|
||||
@ -4205,7 +4205,7 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
||||
|
||||
//glEnable( GL_SCISSOR_TEST );
|
||||
//glScissor(screenPosX, screenPosY,screenPosX-clientW, screenPosY-clientH);
|
||||
|
||||
|
||||
//int newX = screenPosX - (metrics.getVirtualW() / 2);
|
||||
//int newY = screenPosY - (metrics.getVirtualH() / 2);
|
||||
//int newX = 0;
|
||||
@ -4401,21 +4401,21 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
||||
|
||||
if(renderToTexture != NULL) {
|
||||
|
||||
//*renderToTexture = saveScreenToTexture(screenPosX, screenPosY, metrics.getVirtualW(), metrics.getVirtualH());
|
||||
//*renderToTexture = saveScreenToTexture(0, 0, metrics.getVirtualW(), metrics.getVirtualH());
|
||||
// *renderToTexture = saveScreenToTexture(screenPosX, screenPosY, metrics.getVirtualW(), metrics.getVirtualH());
|
||||
// *renderToTexture = saveScreenToTexture(0, 0, metrics.getVirtualW(), metrics.getVirtualH());
|
||||
/*
|
||||
Texture2DGl *texture = static_cast<Texture2DGl *>(*renderToTexture);
|
||||
if(texture != NULL) {
|
||||
//*renderToTexture = saveScreenToTexture(screenPosX, screenPosY, clientW, clientH);
|
||||
// *renderToTexture = saveScreenToTexture(screenPosX, screenPosY, clientW, clientH);
|
||||
texture->dettachFrameBufferFromTexture();
|
||||
|
||||
// Signal the threads queue to add a screenshot save request
|
||||
//MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor);
|
||||
//saveScreenQueue.push_back(make_pair("bob.png",texture->getPixmap()));
|
||||
//*renderToTexture=NULL;
|
||||
//safeMutex.ReleaseLock();
|
||||
// MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor);
|
||||
// saveScreenQueue.push_back(make_pair("bob.png",texture->getPixmap()));
|
||||
// *renderToTexture=NULL;
|
||||
// safeMutex.ReleaseLock();
|
||||
|
||||
//texture->teardown_FBO_RBO();
|
||||
// texture->teardown_FBO_RBO();
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -4424,9 +4424,9 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
||||
|
||||
// setLastRenderFps and calculate shadowsOffDueToMinRender
|
||||
void Renderer::setLastRenderFps(int value) {
|
||||
lastRenderFps = value;
|
||||
lastRenderFps = value;
|
||||
smoothedRenderFps=(MIN_FPS_NORMAL_RENDERING*smoothedRenderFps+lastRenderFps)/(MIN_FPS_NORMAL_RENDERING+1.0f);
|
||||
|
||||
|
||||
if(smoothedRenderFps>=MIN_FPS_NORMAL_RENDERING_TOP_THRESHOLD){
|
||||
shadowsOffDueToMinRender=false;
|
||||
}
|
||||
|
@ -114,6 +114,7 @@ MainWindow::MainWindow()
|
||||
//view
|
||||
menuView = new wxMenu();
|
||||
menuView->Append(miViewResetZoomAndPos, wxT("&Reset zoom and pos"));
|
||||
menuView->AppendCheckItem(miViewGrid, wxT("&Grid"));
|
||||
menuView->AppendSeparator();
|
||||
menuView->Append(miViewHelp, wxT("&Help..."));
|
||||
menuView->Append(miViewAbout, wxT("&About..."));
|
||||
@ -293,15 +294,15 @@ MainWindow::MainWindow()
|
||||
toolbar2->AddTool(miBrushHeight +10, _("brush_height_p4"), wxBitmap(brush_height_p4));
|
||||
toolbar2->AddTool(miBrushHeight +11, _("brush_height_p5"), wxBitmap(brush_height_p5));
|
||||
toolbar2->AddSeparator();
|
||||
toolbar2->AddTool(miRadius + 1, _("radius1"), wxBitmap(radius_1));
|
||||
toolbar2->AddTool(miRadius + 2, _("radius2"), wxBitmap(radius_2));
|
||||
toolbar2->AddTool(miRadius + 3, _("radius3"), wxBitmap(radius_3));
|
||||
toolbar2->AddTool(miRadius + 4, _("radius4"), wxBitmap(radius_4));
|
||||
toolbar2->AddTool(miRadius + 5, _("radius5"), wxBitmap(radius_5));
|
||||
toolbar2->AddTool(miRadius + 6, _("radius6"), wxBitmap(radius_6));
|
||||
toolbar2->AddTool(miRadius + 7, _("radius7"), wxBitmap(radius_7));
|
||||
toolbar2->AddTool(miRadius + 8, _("radius8"), wxBitmap(radius_8));
|
||||
toolbar2->AddTool(miRadius + 9, _("radius9"), wxBitmap(radius_9));
|
||||
toolbar2->AddTool(miRadius + 1, _("radius1"), wxBitmap(radius_1), _("1 (1x1)"));
|
||||
toolbar2->AddTool(miRadius + 2, _("radius2"), wxBitmap(radius_2), _("2 (3x3)"));
|
||||
toolbar2->AddTool(miRadius + 3, _("radius3"), wxBitmap(radius_3), _("3 (5x5)"));
|
||||
toolbar2->AddTool(miRadius + 4, _("radius4"), wxBitmap(radius_4), _("4 (7x7)"));
|
||||
toolbar2->AddTool(miRadius + 5, _("radius5"), wxBitmap(radius_5), _("5 (9x9)"));
|
||||
toolbar2->AddTool(miRadius + 6, _("radius6"), wxBitmap(radius_6), _("6 (11x11)"));
|
||||
toolbar2->AddTool(miRadius + 7, _("radius7"), wxBitmap(radius_7), _("7 (13x13)"));
|
||||
toolbar2->AddTool(miRadius + 8, _("radius8"), wxBitmap(radius_8), _("8 (15x15)"));
|
||||
toolbar2->AddTool(miRadius + 9, _("radius9"), wxBitmap(radius_9), _("9 (17x17)"));
|
||||
toolbar2->Realize();
|
||||
|
||||
wxBoxSizer *boxsizer = new wxBoxSizer(wxVERTICAL);
|
||||
@ -708,7 +709,7 @@ void MainWindow::onMenuEditInfo(wxCommandEvent &event) {
|
||||
void MainWindow::onMenuEditAdvanced(wxCommandEvent &event) {
|
||||
SimpleDialog simpleDialog;
|
||||
simpleDialog.addValue("Height Factor", intToStr(program->getMap()->getHeightFactor()),"(lower means map is more more zoomed in)");
|
||||
simpleDialog.addValue("Water Level", intToStr(program->getMap()->getWaterLevel()),"(which level water is visible but still walkable)");
|
||||
simpleDialog.addValue("Water Level", intToStr(program->getMap()->getWaterLevel()),"(water is visible below this, and walkable until 1.5 less)");
|
||||
if (!simpleDialog.show("Advanced")) return;
|
||||
|
||||
try {
|
||||
@ -728,6 +729,13 @@ void MainWindow::onMenuViewResetZoomAndPos(wxCommandEvent &event) {
|
||||
onPaint(e);
|
||||
}
|
||||
|
||||
void MainWindow::onMenuViewGrid(wxCommandEvent &event) {
|
||||
menuView->Check(miViewGrid, program->setGridOnOff()); // miViewGrid event.GetId()
|
||||
wxPaintEvent e;
|
||||
onPaint(e);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onMenuViewAbout(wxCommandEvent &event) {
|
||||
MsgDialog(
|
||||
this,
|
||||
@ -739,8 +747,10 @@ void MainWindow::onMenuViewHelp(wxCommandEvent &event) {
|
||||
MsgDialog(this,
|
||||
wxT("Draw with left mouse\nMove viewport with right mouse drag\nZoom with center mouse drag, or mousewheel\n\
|
||||
You can change brush in the same category with key 1-9\n\
|
||||
Height tool (blue) builds with integer height steps 0-20, \nwhile Gradient tool (red) uses any real number \n\
|
||||
Units can go over water as long as it is less than 1.5 deep\n\
|
||||
A good idea is to put some stone, gold and tree near starting position\n\
|
||||
Starting position needs an open area for the tower and at starting units\n"),
|
||||
Starting position needs an open area for the tower and the starting units\n"),
|
||||
wxT("Help")).ShowModal();
|
||||
/* 5 away and 10x10 empty area? */
|
||||
}
|
||||
@ -996,6 +1006,7 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
||||
EVT_MENU(miEditAdvanced, MainWindow::onMenuEditAdvanced)
|
||||
|
||||
EVT_MENU(miViewResetZoomAndPos, MainWindow::onMenuViewResetZoomAndPos)
|
||||
EVT_MENU(miViewGrid, MainWindow::onMenuViewGrid)
|
||||
EVT_MENU(miViewAbout, MainWindow::onMenuViewAbout)
|
||||
EVT_MENU(miViewHelp, MainWindow::onMenuViewHelp)
|
||||
|
||||
|
@ -123,6 +123,7 @@ private:
|
||||
miEditAdvanced,
|
||||
|
||||
miViewResetZoomAndPos,
|
||||
miViewGrid,
|
||||
miViewAbout,
|
||||
miViewHelp,
|
||||
|
||||
@ -222,6 +223,7 @@ public:
|
||||
void onMenuEditAdvanced(wxCommandEvent &event);
|
||||
|
||||
void onMenuViewResetZoomAndPos(wxCommandEvent &event);
|
||||
void onMenuViewGrid(wxCommandEvent &event);
|
||||
void onMenuViewAbout(wxCommandEvent &event);
|
||||
void onMenuViewHelp(wxCommandEvent &event);
|
||||
|
||||
|
@ -9,8 +9,9 @@
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
// This file is not used anoymore
|
||||
// This file is not used anymore
|
||||
|
||||
/*
|
||||
#include "map.h"
|
||||
|
||||
#include <cmath>
|
||||
@ -349,12 +350,12 @@ void Map::mirrorXY() { // copy leftbottom to topright
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
void Map::rotatecopyX();
|
||||
void Map::rotatecopyY();
|
||||
void Map::rotatecopyXY();
|
||||
void Map::rotatecopyCorner();
|
||||
*/
|
||||
|
||||
// void Map::rotatecopyX();
|
||||
// void Map::rotatecopyY();
|
||||
// void Map::rotatecopyXY();
|
||||
// void Map::rotatecopyCorner();
|
||||
|
||||
|
||||
void Map::changeSurface(int x, int y, int surface, int radius) {
|
||||
int i, j;
|
||||
@ -804,4 +805,6 @@ void Map::applyNewHeight(float newHeight, int x, int y, int strenght) {
|
||||
|
||||
}// end namespace
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
@ -9,8 +9,9 @@
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
// This file is not used anoymore
|
||||
// This file is not used anymore
|
||||
|
||||
/*
|
||||
#ifndef _MAPEDITOR_MAP_H_
|
||||
#define _MAPEDITOR_MAP_H_
|
||||
|
||||
@ -141,3 +142,6 @@ public:
|
||||
}// end namespace
|
||||
|
||||
#endif
|
||||
|
||||
*/
|
||||
|
||||
|
@ -146,6 +146,7 @@ MapPreview *Program::map = NULL;
|
||||
|
||||
Program::Program(int w, int h) {
|
||||
cellSize = 6;
|
||||
grid=false;
|
||||
ofsetX = 0;
|
||||
ofsetY = 0;
|
||||
map = new MapPreview();
|
||||
@ -178,6 +179,7 @@ int Program::getResource(int x, int y) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move editor-specific code from shared_lib to here.
|
||||
void Program::glestChangeMapHeight(int x, int y, int Height, int radius) {
|
||||
map->glestChangeHeight((x - ofsetX) / cellSize, (y + ofsetY) / cellSize, Height, radius);
|
||||
}
|
||||
@ -238,7 +240,7 @@ bool Program::redo() {
|
||||
}
|
||||
|
||||
void Program::renderMap(int w, int h) {
|
||||
renderer.renderMap(map, ofsetX, ofsetY, w, h, cellSize);
|
||||
renderer.renderMap(map, ofsetX, ofsetY, w, h, cellSize, grid);
|
||||
}
|
||||
|
||||
void Program::setRefAlt(int x, int y) {
|
||||
@ -444,6 +446,11 @@ void Program::resetOfset() {
|
||||
cellSize = 6;
|
||||
}
|
||||
|
||||
bool Program::setGridOnOff() {
|
||||
grid=!grid;
|
||||
return grid;
|
||||
}
|
||||
|
||||
void Program::setMapAdvanced(int altFactor, int waterLevel) {
|
||||
map->setAdvanced(altFactor, waterLevel);
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ private:
|
||||
BaseRenderer renderer;
|
||||
int ofsetX, ofsetY;
|
||||
int cellSize;
|
||||
bool grid; // show grid option
|
||||
//static Map *map;
|
||||
static MapPreview *map;
|
||||
friend class UndoPoint;
|
||||
@ -151,6 +152,7 @@ public:
|
||||
void setOfset(int x, int y);
|
||||
void incCellSize(int i);
|
||||
void resetOfset();
|
||||
bool setGridOnOff();
|
||||
|
||||
int getObject(int x, int y);
|
||||
int getResource(int x, int y);
|
||||
|
@ -9,6 +9,9 @@
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
//this file is not used
|
||||
|
||||
/*
|
||||
|
||||
#include "renderer.h"
|
||||
|
||||
@ -37,7 +40,7 @@ void Renderer::init(int clientW, int clientH) {
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void Renderer::renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize) {
|
||||
void Renderer::renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid) {
|
||||
float alt;
|
||||
float showWater;
|
||||
|
||||
@ -129,13 +132,13 @@ void Renderer::renderMap(MapPreview *map, int x, int y, int clientW, int clientH
|
||||
|
||||
glColor3fv((surfColor*2.f).ptr());
|
||||
//left
|
||||
if (i > 0 && map->getHeight(i - 1, j) < map->getHeight(i, j)) {
|
||||
if (grid || (i > 0 && map->getHeight(i - 1, j) < map->getHeight(i, j))) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(i * cellSize, clientH - (j + 1) * cellSize);
|
||||
glVertex2i(i * cellSize, clientH - j * cellSize);
|
||||
glEnd();
|
||||
}
|
||||
if (j > 0 && map->getHeight(i, j - 1) < map->getHeight(i, j)) {
|
||||
if (grid || (j > 0 && map->getHeight(i, j - 1) < map->getHeight(i, j))) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(i * cellSize, clientH - j * cellSize);
|
||||
glVertex2i((i + 1) * cellSize, clientH - j * cellSize);
|
||||
@ -191,4 +194,8 @@ void Renderer::renderMap(MapPreview *map, int x, int y, int clientW, int clientH
|
||||
assertGl();
|
||||
}
|
||||
|
||||
|
||||
}// end namespace
|
||||
|
||||
*/
|
||||
|
||||
|
@ -9,6 +9,11 @@
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
|
||||
//this file is not used
|
||||
|
||||
/*
|
||||
|
||||
#ifndef _MAPEDITOR_RENDERER_H_
|
||||
#define _MAPEDITOR_RENDERER_H_
|
||||
|
||||
@ -25,9 +30,11 @@ namespace MapEditor {
|
||||
class Renderer {
|
||||
public:
|
||||
void init(int clientW, int clientH);
|
||||
void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize);
|
||||
void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid=false);
|
||||
};
|
||||
|
||||
}// end namespace
|
||||
|
||||
#endif
|
||||
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
~BaseRenderer() { }
|
||||
|
||||
virtual void initMapSurface(int clientW, int clientH);
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize);
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid=false);
|
||||
};
|
||||
|
||||
}} // end namespace
|
||||
|
@ -3,9 +3,9 @@
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// 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
|
||||
// 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
|
||||
// ==============================================================
|
||||
|
||||
@ -41,11 +41,11 @@ public:
|
||||
class RendererMapInterface {
|
||||
public:
|
||||
virtual void initMapSurface(int clientW, int clientH) = 0;
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize) = 0;
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid) = 0;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class GraphicsInterface
|
||||
// class GraphicsInterface
|
||||
//
|
||||
/// Interface for the graphic engine
|
||||
// =====================================================
|
||||
@ -68,7 +68,7 @@ public:
|
||||
static GraphicsInterface &getInstance();
|
||||
|
||||
void setFactory(GraphicsFactory *graphicsFactory);
|
||||
void setCurrentContext(Context *context);
|
||||
void setCurrentContext(Context *context);
|
||||
|
||||
Context *getCurrentContext() const {return currentContext;}
|
||||
GraphicsFactory *getFactory() const {return graphicsFactory;}
|
||||
|
@ -36,7 +36,7 @@ void BaseRenderer::initMapSurface(int clientW, int clientH) {
|
||||
}
|
||||
|
||||
void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
||||
int clientW, int clientH, int cellSize) {
|
||||
int clientW, int clientH, int cellSize, bool grid) {
|
||||
float alt=0;
|
||||
float showWater=0;
|
||||
|
||||
@ -112,14 +112,14 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
||||
// if (!found) {
|
||||
glColor3fv((surfColor*0.5f).ptr());
|
||||
//left
|
||||
if (i > 0 && map->getHeight(i - 1, j) > map->getHeight(i, j)) {
|
||||
if (grid || (i > 0 && map->getHeight(i - 1, j) > map->getHeight(i, j))) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(i * cellSize, clientH - (j + 1) * cellSize);
|
||||
glVertex2i(i * cellSize, clientH - j * cellSize);
|
||||
glEnd();
|
||||
}
|
||||
//down
|
||||
if (j > 0 && map->getHeight(i, j - 1) > map->getHeight(i, j)) {
|
||||
if (grid || (j > 0 && map->getHeight(i, j - 1) > map->getHeight(i, j))) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(i * cellSize, clientH - j * cellSize);
|
||||
glVertex2i((i + 1) * cellSize, clientH - j * cellSize);
|
||||
|
@ -83,8 +83,7 @@ int MapPreview::getStartLocationY(int index) const {
|
||||
static int get_dist(int delta_x, int delta_y) {
|
||||
float dx = (float)delta_x;
|
||||
float dy = (float)delta_y;
|
||||
|
||||
return static_cast<int>(sqrtf(dx * dx + dy * dy));
|
||||
return static_cast<int>(sqrtf(dx * dx + dy * dy)+0.5); // round correctly
|
||||
}
|
||||
|
||||
void MapPreview::glestChangeHeight(int x, int y, int height, int radius) {
|
||||
@ -169,8 +168,8 @@ void MapPreview::pirateChangeHeight(int x, int y, int height, int radius) {
|
||||
}
|
||||
//std::cout << endl;
|
||||
|
||||
// A brush with radius n cells should have a true radius of n-1 distance
|
||||
radius -= 1;
|
||||
// // A brush with radius n cells should have a true radius of n-1 distance // No becasue then "radius" 1==2
|
||||
// radius -= 1;
|
||||
for (int i = x - radius; i <= x + radius; i++) {
|
||||
for (int j = y - radius; j <= y + radius; j++) {
|
||||
int dist = get_dist(i - x, j - y);
|
||||
@ -360,7 +359,7 @@ void MapPreview::changeSurface(int x, int y, MapSurfaceType surface, int radius)
|
||||
for (j = y - radius + 1; j < y + radius; j++) {
|
||||
if (inside(i, j)) {
|
||||
dist = get_dist(i - x, j - y);
|
||||
if (radius >= dist) {
|
||||
if (radius > dist) { // was >=
|
||||
cells[i][j].surface = surface;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user