Skip to content

Commit ff3d9e0

Browse files
committed
Add map overview
1 parent 39dc9dd commit ff3d9e0

11 files changed

Lines changed: 170 additions & 4 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ DISTNAME = editor21.0.0
3838
DISTDIR = /home/segra/editor2/.tmp/editor21.0.0
3939
LINK = g++
4040
LFLAGS = -Wl,-O1
41-
LIBS = $(SUBLIBS) -lSDL2 -lSDL2_mixer -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
41+
LIBS = $(SUBLIBS) -lSDL2 -lSDL2_mixer -lQt6Widgets -lQt6Gui -lQt6Core -lGL -lpthread
4242
AR = ar cqs
4343
RANLIB =
4444
SED = sed
@@ -312,7 +312,7 @@ TARGET = editor2
312312
first: all
313313
####### Build rules
314314

315-
$(TARGET): ui_ofed.h ui_CampaignDialog.h ui_NewMapDialog.h ui_ToolboxSprites.h ui_ToolboxTiles.h $(OBJECTS)
315+
$(TARGET): ui_ofed.h ui_CampaignDialog.h ui_NewMapDialog.h ui_ToolboxSprites.h ui_ToolboxTiles.h ui_MapView.h $(OBJECTS)
316316
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
317317

318318
Makefile: editor2.pro /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++/qmake.conf /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/spec_pre.prf \

Project/VS2017/ofed.ui

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<x>0</x>
3737
<y>0</y>
3838
<width>948</width>
39-
<height>21</height>
39+
<height>22</height>
4040
</rect>
4141
</property>
4242
<widget class="QMenu" name="menu_File">
@@ -58,6 +58,8 @@
5858
<addaction name="action_Load_Map"/>
5959
<addaction name="action_Save_Map"/>
6060
<addaction name="separator"/>
61+
<addaction name="actionMap_Overview"/>
62+
<addaction name="separator"/>
6163
<addaction name="actionExit"/>
6264
</widget>
6365
<widget class="QMenu" name="menuInsert">
@@ -215,6 +217,11 @@
215217
<string>New Phase</string>
216218
</property>
217219
</action>
220+
<action name="actionMap_Overview">
221+
<property name="text">
222+
<string>Map Overview</string>
223+
</property>
224+
</action>
218225
</widget>
219226
<layoutdefault spacing="6" margin="11"/>
220227
<customwidgets>

Project/VS2017/ofed.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@
323323
<ClCompile Include="..\..\Dependencies\OpenFodder\Source\Versions.cpp" />
324324
<ClCompile Include="..\..\Dependencies\OpenFodder\Source\Window.cpp" />
325325
<ClCompile Include="..\..\Source\Dialogs\CampaignDialog.cpp" />
326+
<ClCompile Include="..\..\Source\Dialogs\MapView.cpp" />
326327
<ClCompile Include="..\..\Source\Dialogs\NewMapDialog.cpp" />
327328
<ClCompile Include="..\..\Source\Dialogs\ToolboxSprites.cpp" />
328329
<ClCompile Include="..\..\Source\Dialogs\ToolboxTiles.cpp" />
@@ -334,6 +335,7 @@
334335
<ClCompile Include="..\..\Source\WindowQT.cpp" />
335336
</ItemGroup>
336337
<ItemGroup>
338+
<QtUic Include="..\..\Source\Dialogs\MapView.ui" />
337339
<QtUic Include="ofed.ui">
338340
</QtUic>
339341
</ItemGroup>
@@ -399,6 +401,7 @@
399401
<ClInclude Include="..\..\Dependencies\OpenFodder\Source\Versions_Files.hpp" />
400402
<ClInclude Include="..\..\Dependencies\OpenFodder\Source\Window.hpp" />
401403
<ClInclude Include="..\..\Source\Dialogs\CampaignDialog.hpp" />
404+
<ClInclude Include="..\..\Source\Dialogs\MapView.hpp" />
402405
<ClInclude Include="..\..\Source\Dialogs\NewMapDialog.hpp" />
403406
<ClInclude Include="..\..\Source\Dialogs\ToolboxSprites.hpp" />
404407
<ClInclude Include="..\..\Source\Dialogs\ToolboxTiles.hpp" />

Project/VS2017/ofed.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@
221221
<ClCompile Include="..\..\Dependencies\OpenFodder\Source\Utils\SimplexIslands.cpp">
222222
<Filter>OpenFodder\Utils</Filter>
223223
</ClCompile>
224+
<ClCompile Include="..\..\Source\Dialogs\MapView.cpp">
225+
<Filter>Source Files\Dialog</Filter>
226+
</ClCompile>
224227
</ItemGroup>
225228
<ItemGroup>
226229
<QtUic Include="ofed.ui">
@@ -244,6 +247,9 @@
244247
<QtUic Include="..\..\Source\Dialogs\CampaignDialog.ui">
245248
<Filter>Source Files\Dialog</Filter>
246249
</QtUic>
250+
<QtUic Include="..\..\Source\Dialogs\MapView.ui">
251+
<Filter>Source Files\Dialog</Filter>
252+
</QtUic>
247253
</ItemGroup>
248254
<ItemGroup>
249255
<ClInclude Include="GeneratedFiles\ui_ofed.h">
@@ -468,6 +474,9 @@
468474
<ClInclude Include="..\..\Dependencies\OpenFodder\Source\Utils\SimplexIslands.hpp">
469475
<Filter>OpenFodder\Utils</Filter>
470476
</ClInclude>
477+
<ClInclude Include="..\..\Source\Dialogs\MapView.hpp">
478+
<Filter>Source Files\Dialog</Filter>
479+
</ClInclude>
471480
</ItemGroup>
472481
<ItemGroup>
473482
<None Include="packages.config" />

Source/Dialogs/MapView.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "stdafx_ofed.hpp"
2+
#include "ofed.hpp"
3+
#include "ui_MapView.h"
4+
5+
#include <qpixmap.h>
6+
#include <qpainter.h>
7+
#include <qevent.h>
8+
9+
cMapView::cMapView( QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {
10+
11+
mUi = new Ui_MapView();
12+
mUi->setupUi(this);
13+
RenderTiles();
14+
}
15+
16+
cMapView::~cMapView() {
17+
18+
}
19+
20+
void cMapView::RenderTiles() {
21+
22+
g_Fodder->Map_Overview_Prepare();
23+
g_Fodder->mGraphics->PaletteSetOverview();
24+
g_Fodder->mSurfaceMapOverview->draw();
25+
// Copy the image into a QImage
26+
SDL_Surface* Source = g_Fodder->mSurfaceMapOverview->GetSurface();
27+
mImage = QImage(static_cast<uchar*>(Source->pixels), Source->w, Source->h, QImage::Format_RGB32);
28+
this->repaint();
29+
30+
}
31+
32+
void cMapView::paintEvent(QPaintEvent*) {
33+
34+
mScaleWidth = (static_cast<double>(size().width()) / static_cast<double>(mImage.width()));
35+
mScaleHeight = (static_cast<double>(size().height()) / static_cast<double>(mImage.height()));
36+
37+
QPainter painter(this);
38+
QRectF Dest(0, 0, size().width(), size().height());
39+
QRectF Src(0, 0, mImage.width(), mImage.height());
40+
41+
painter.drawImage(Dest, mImage, Src);
42+
}
43+

Source/Dialogs/MapView.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Ui_MapView;
2+
3+
class cMapView : public QDialog {
4+
Ui_MapView *mUi;
5+
6+
QImage mImage;
7+
8+
double mScaleWidth, mScaleHeight;
9+
10+
protected:
11+
12+
void paintEvent(QPaintEvent* e) override;
13+
14+
public:
15+
cMapView( QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
16+
~cMapView();
17+
18+
void RenderTiles();
19+
20+
};

Source/Dialogs/MapView.ui

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>MapView</class>
4+
<widget class="QDialog" name="MapView">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>991</width>
10+
<height>865</height>
11+
</rect>
12+
</property>
13+
<property name="mouseTracking">
14+
<bool>true</bool>
15+
</property>
16+
<property name="windowTitle">
17+
<string>Map Overview</string>
18+
</property>
19+
<layout class="QVBoxLayout" name="verticalLayout_2">
20+
<property name="spacing">
21+
<number>0</number>
22+
</property>
23+
<property name="leftMargin">
24+
<number>0</number>
25+
</property>
26+
<property name="topMargin">
27+
<number>0</number>
28+
</property>
29+
<property name="rightMargin">
30+
<number>0</number>
31+
</property>
32+
<property name="bottomMargin">
33+
<number>0</number>
34+
</property>
35+
<item>
36+
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
37+
<property name="spacing">
38+
<number>0</number>
39+
</property>
40+
<item>
41+
<widget class="QWidget" name="mSurfaceTiles" native="true">
42+
<property name="mouseTracking">
43+
<bool>true</bool>
44+
</property>
45+
</widget>
46+
</item>
47+
<item>
48+
<widget class="QLabel" name="mCurrentTile">
49+
<property name="mouseTracking">
50+
<bool>true</bool>
51+
</property>
52+
<property name="text">
53+
<string>TextLabel</string>
54+
</property>
55+
<property name="alignment">
56+
<set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
57+
</property>
58+
</widget>
59+
</item>
60+
</layout>
61+
</item>
62+
</layout>
63+
</widget>
64+
<resources/>
65+
<connections/>
66+
</ui>

Source/OFED.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ cOFED::cOFED(QWidget *parent) : QMainWindow(parent) {
2525
mToolboxTiles = 0;
2626
mToolboxSprites = 0;
2727
mMapSub = 0;
28+
mMapView = 0;
2829

2930
delete ui.mSurface;
3031
g_Window = std::make_shared<cWindowQT> (ui.centralWidget);
@@ -64,6 +65,8 @@ cOFED::cOFED(QWidget *parent) : QMainWindow(parent) {
6465
QObject::connect(ui.actionNew_Mission, &QAction::triggered, this, &cOFED::Mission_AddNew);
6566
QObject::connect(ui.actionNew_Phase, &QAction::triggered, this, &cOFED::Phase_AddNew);
6667

68+
QObject::connect(ui.actionMap_Overview, &QAction::triggered, this, &cOFED::ShowDialog_MapOverview);
69+
6770
g_Debugger = std::make_shared<cDebugger>();
6871
g_Fodder = std::make_shared<cFodder>(g_Window);
6972

@@ -876,6 +879,11 @@ void cOFED::AddCliff() {
876879
setCursorTiles(Tiles);
877880
}
878881

882+
void cOFED::ShowDialog_MapOverview() {
883+
mMapView = new cMapView(this);
884+
mMapView->show();
885+
}
886+
879887
void cOFED::ShowDialog_NewCampaign() {
880888

881889
QString fileName = QFileDialog::getSaveFileName(this,
@@ -1023,6 +1031,9 @@ void cOFED::Create_NewMap(const std::string& pTileSet, const std::string& pTileS
10231031
// Update the Toolboxes
10241032
mToolboxSprites->RenderSprites();
10251033
mToolboxTiles->RenderTiles();
1034+
1035+
if (mMapView)
1036+
mMapView->RenderTiles();
10261037
return;
10271038
}
10281039
}
@@ -1089,6 +1100,8 @@ void cOFED::LoadMap() {
10891100
g_Fodder->Mission_Sprites_Handle();
10901101
g_Fodder->mWindow->FrameEnd();
10911102

1103+
if(mMapView)
1104+
mMapView->RenderTiles();
10921105
}
10931106

10941107
/**

Source/gitver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const char* gitversion="b7992fe";
1+
const char* gitversion="39dc9dd";

Source/ofed.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class cOFED : public QMainWindow
7474

7575
void AddCliff();
7676

77+
78+
void ShowDialog_MapOverview();
79+
7780
void ShowDialog_NewCampaign();
7881
void ShowDialog_LoadCampaign();
7982
void ShowDialog_SaveCampaign();
@@ -109,6 +112,7 @@ class cOFED : public QMainWindow
109112

110113
private:
111114
Ui::mOFED ui;
115+
cMapView* mMapView;
112116
cCampaignDialog* mToolboxCampaigns;
113117
cToolboxTiles* mToolboxTiles;
114118
cToolboxSprites* mToolboxSprites;

0 commit comments

Comments
 (0)