Objects and ressources under the mouse are displayed.
Hitting space can be used to select the brush for objects/ressources currently under the mouse.
This commit is contained in:
parent
983d8475c9
commit
3041efaa77
|
@ -55,6 +55,8 @@ MainWindow::MainWindow()
|
||||||
startLocation=1;
|
startLocation=1;
|
||||||
enabledGroup=ctHeight;
|
enabledGroup=ctHeight;
|
||||||
currentBrush=btHeight;
|
currentBrush=btHeight;
|
||||||
|
resourceUnderMouse=0;
|
||||||
|
objectUnderMouse=0;
|
||||||
|
|
||||||
//gl canvas
|
//gl canvas
|
||||||
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER };
|
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER };
|
||||||
|
@ -177,7 +179,8 @@ MainWindow::MainWindow()
|
||||||
int status_widths[siCOUNT] = {
|
int status_widths[siCOUNT] = {
|
||||||
10, // empty
|
10, // empty
|
||||||
-2, // File name
|
-2, // File name
|
||||||
-2, // File type
|
-1, // File type
|
||||||
|
-2, // Current Object
|
||||||
-2, // Brush Type
|
-2, // Brush Type
|
||||||
-2, // Brush 'Value'
|
-2, // Brush 'Value'
|
||||||
-1, // Brush Radius
|
-1, // Brush Radius
|
||||||
|
@ -186,7 +189,8 @@ MainWindow::MainWindow()
|
||||||
GetStatusBar()->SetStatusWidths(siCOUNT, status_widths);
|
GetStatusBar()->SetStatusWidths(siCOUNT, status_widths);
|
||||||
|
|
||||||
SetStatusText(wxT("File: ") + ToUnicode(fileName), siFILE_NAME);
|
SetStatusText(wxT("File: ") + ToUnicode(fileName), siFILE_NAME);
|
||||||
SetStatusText(wxT("Type: Glest Map (gbm)"), siFILE_TYPE);
|
SetStatusText(wxT(".gbm"), siFILE_TYPE);
|
||||||
|
SetStatusText(wxT("Object: None (Erase)"), siCURR_OBJECT);
|
||||||
SetStatusText(wxT("Brush: Height"), siBRUSH_TYPE);
|
SetStatusText(wxT("Brush: Height"), siBRUSH_TYPE);
|
||||||
SetStatusText(wxT("Value: 0"), siBRUSH_VALUE);
|
SetStatusText(wxT("Value: 0"), siBRUSH_VALUE);
|
||||||
SetStatusText(wxT("Radius: 1"), siBRUSH_RADIUS);
|
SetStatusText(wxT("Radius: 1"), siBRUSH_RADIUS);
|
||||||
|
@ -243,10 +247,10 @@ void MainWindow::setExtension() {
|
||||||
currentFile = cutLastExt(currentFile);
|
currentFile = cutLastExt(currentFile);
|
||||||
}
|
}
|
||||||
if (Program::getMap()->getMaxFactions() <= 4) {
|
if (Program::getMap()->getMaxFactions() <= 4) {
|
||||||
SetStatusText(wxT("Type: Glest Map (gbm)"), siFILE_TYPE);
|
SetStatusText(wxT(".gbm"), siFILE_TYPE);
|
||||||
currentFile += ".gbm";
|
currentFile += ".gbm";
|
||||||
} else {
|
} else {
|
||||||
SetStatusText(wxT("Type: Mega Map (mgm)"), siFILE_TYPE);
|
SetStatusText(wxT(".mgm"), siFILE_TYPE);
|
||||||
currentFile += ".mgm";
|
currentFile += ".mgm";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,6 +258,7 @@ void MainWindow::setExtension() {
|
||||||
void MainWindow::onTimer(wxTimerEvent &event) {
|
void MainWindow::onTimer(wxTimerEvent &event) {
|
||||||
wxPaintEvent paintEvent;
|
wxPaintEvent paintEvent;
|
||||||
onPaint(paintEvent);
|
onPaint(paintEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMouseDown(wxMouseEvent &event) {
|
void MainWindow::onMouseDown(wxMouseEvent &event) {
|
||||||
|
@ -295,6 +300,21 @@ void MainWindow::onMouseMove(wxMouseEvent &event) {
|
||||||
wxPaintEvent ev;
|
wxPaintEvent ev;
|
||||||
onPaint(ev);
|
onPaint(ev);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int currResource = program->getResource(x,y);
|
||||||
|
if(currResource>0){
|
||||||
|
SetStatusText(wxT("Resource: ") + ToUnicode(resource_descs[currResource]), siCURR_OBJECT);
|
||||||
|
resourceUnderMouse = currResource;
|
||||||
|
objectUnderMouse = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int currObject = program->getObject(x,y);
|
||||||
|
SetStatusText(wxT("Object: ") + ToUnicode(object_descs[currObject]), siCURR_OBJECT);
|
||||||
|
resourceUnderMouse = 0;
|
||||||
|
objectUnderMouse = currObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,6 +710,17 @@ void MainWindow::uncheckRadius() {
|
||||||
if (e.GetKeyCode() == 'H') {
|
if (e.GetKeyCode() == 'H') {
|
||||||
wxCommandEvent evt(wxEVT_NULL, miBrushHeight + height + heightCount / 2 + 1);
|
wxCommandEvent evt(wxEVT_NULL, miBrushHeight + height + heightCount / 2 + 1);
|
||||||
onMenuBrushHeight(evt);
|
onMenuBrushHeight(evt);
|
||||||
|
} else if (e.GetKeyCode() == ' ') {
|
||||||
|
if( resourceUnderMouse != 0 )
|
||||||
|
{
|
||||||
|
wxCommandEvent evt(wxEVT_NULL, miBrushResource + resourceUnderMouse + 1);
|
||||||
|
onMenuBrushResource(evt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxCommandEvent evt(wxEVT_NULL, miBrushObject + objectUnderMouse + 1);
|
||||||
|
onMenuBrushObject(evt);
|
||||||
|
}
|
||||||
} else if (e.GetKeyCode() == 'G') {
|
} else if (e.GetKeyCode() == 'G') {
|
||||||
wxCommandEvent evt(wxEVT_NULL, miBrushGradient + height + heightCount / 2 + 1);
|
wxCommandEvent evt(wxEVT_NULL, miBrushGradient + height + heightCount / 2 + 1);
|
||||||
onMenuBrushGradient(evt);
|
onMenuBrushGradient(evt);
|
||||||
|
|
|
@ -43,6 +43,7 @@ enum StatusItems {
|
||||||
siNULL_ENTRY,
|
siNULL_ENTRY,
|
||||||
siFILE_NAME,
|
siFILE_NAME,
|
||||||
siFILE_TYPE,
|
siFILE_TYPE,
|
||||||
|
siCURR_OBJECT,
|
||||||
siBRUSH_TYPE,
|
siBRUSH_TYPE,
|
||||||
siBRUSH_VALUE,
|
siBRUSH_VALUE,
|
||||||
siBRUSH_RADIUS,
|
siBRUSH_RADIUS,
|
||||||
|
@ -155,6 +156,9 @@ private:
|
||||||
int object;
|
int object;
|
||||||
int resource;
|
int resource;
|
||||||
int startLocation;
|
int startLocation;
|
||||||
|
int resourceUnderMouse;
|
||||||
|
int objectUnderMouse;
|
||||||
|
|
||||||
ChangeType enabledGroup;
|
ChangeType enabledGroup;
|
||||||
|
|
||||||
string fileName;
|
string fileName;
|
||||||
|
|
|
@ -155,6 +155,28 @@ Program::~Program() {
|
||||||
delete map;
|
delete map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Program::getObject(int x, int y) {
|
||||||
|
int i=(x - ofsetX) / cellSize;
|
||||||
|
int j= (y + ofsetY) / cellSize;
|
||||||
|
if (map->inside(i, j)) {
|
||||||
|
map->getObject(i,j);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Program::getResource(int x, int y) {
|
||||||
|
int i=(x - ofsetX) / cellSize;
|
||||||
|
int j= (y + ofsetY) / cellSize;
|
||||||
|
if (map->inside(i, j)) {
|
||||||
|
map->getResource(i,j);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Program::glestChangeMapHeight(int x, int y, int Height, int radius) {
|
void Program::glestChangeMapHeight(int x, int y, int Height, int radius) {
|
||||||
map->glestChangeHeight((x - ofsetX) / cellSize, (y + ofsetY) / cellSize, Height, radius);
|
map->glestChangeHeight((x - ofsetX) / cellSize, (y + ofsetY) / cellSize, Height, radius);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
|
@ -137,6 +137,8 @@ public:
|
||||||
void incCellSize(int i);
|
void incCellSize(int i);
|
||||||
void resetOfset();
|
void resetOfset();
|
||||||
|
|
||||||
|
int getObject(int x, int y);
|
||||||
|
int getResource(int x, int y);
|
||||||
static const Map *getMap() {return map;}
|
static const Map *getMap() {return map;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue