1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-14 02:33:51 +02:00

* map loading

* a bit of map spec window
This commit is contained in:
mateuszb 2013-02-17 12:56:20 +00:00
parent b169326940
commit f083db7c5a
3 changed files with 58 additions and 0 deletions

View File

@ -4,6 +4,8 @@
#include "../lib/VCMIDirs.h"
#include "../lib/Filesystem/CResourceLoader.h"
#include "../lib/CGeneralTextHandler.h"
#include "../lib/Mapping/CMap.h"
#include "../lib/Mapping/CMapService.h"
Editor::Editor(QWidget *parent)
: QMainWindow(parent)
@ -33,6 +35,38 @@ void Editor::createMenus()
enum MenuName {FILE=0, EDIT, VIEW, TOOLS, PLAYER, HELP, //main level
TERRAIN=0, RIVER, ROADS, ERASE, OBSTACLES, OBJECTS}; //tools submenus
//txts are in wrong order
std::swap(txtEditor[793], txtEditor[797]);
std::swap(txtEditor[794], txtEditor[797]);
std::swap(txtEditor[795], txtEditor[797]);
std::swap(txtEditor[796], txtEditor[797]);
//setting up actions
actions["file|1"] = [&]()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
"",
tr("Files (*.h3m)"));
std::ifstream is;
is.open (fileName.toStdString().c_str(), std::ios::binary );
// get length of file
is.seekg (0, std::ios::end);
int length = is.tellg();
is.seekg (0, std::ios::beg);
char* buffer = new char [length];
is.read (buffer, length);
is.close();
map = CMapService::loadMap((ui8*)buffer, length);
};
//setting up menus
QMenu * menus[6];
for(int i=0; i<6; ++i)
menus[i] = menuBar()->addMenu(tr(txtEditor[751+i].c_str()));

View File

@ -5,6 +5,7 @@
#include "ui_editor.h"
class CConsoleHandler;
class CMap;
class Editor : public QMainWindow
{
@ -14,6 +15,9 @@ public:
Editor(QWidget *parent = 0);
~Editor();
void createMenus();
std::unique_ptr<CMap> map;
private:
std::vector<std::string> txtEditor, txtEditorCmd;

View File

@ -85,9 +85,16 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ConfigWindows.cpp">
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdInc.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="Editor.cpp">
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdInc.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="GeneratedFiles\Debug\moc_ConfigWindows.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdInc.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="GeneratedFiles\Debug\moc_Editor.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
@ -97,6 +104,9 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="GeneratedFiles\Release\moc_ConfigWindows.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GeneratedFiles\Release\moc_Editor.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</ClCompile>
@ -110,6 +120,16 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="ConfigWindows.h">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing ConfigWindows.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-fStdInc.h" "-f../../ConfigWindows.h"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing ConfigWindows.h...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../ConfigWindows.h" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command>
</CustomBuild>
<ClInclude Include="GeneratedFiles\ui_editor.h" />
<CustomBuild Include="Editor.h">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>