Initial commit for new map editor
@@ -47,6 +47,7 @@ set(VCMI_VERSION_PATCH 0)
|
|||||||
option(ENABLE_ERM "Enable compilation of ERM scripting module" ON)
|
option(ENABLE_ERM "Enable compilation of ERM scripting module" ON)
|
||||||
option(ENABLE_LUA "Enable compilation of LUA scripting module" ON)
|
option(ENABLE_LUA "Enable compilation of LUA scripting module" ON)
|
||||||
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
|
option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
|
||||||
|
option(ENABLE_EDITOR "Enable compilation of map editor" ON)
|
||||||
option(ENABLE_TEST "Enable compilation of unit tests" ON)
|
option(ENABLE_TEST "Enable compilation of unit tests" ON)
|
||||||
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
|
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
|
||||||
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
|
option(ENABLE_PCH "Enable compilation using precompiled headers" ON)
|
||||||
@@ -247,7 +248,7 @@ if(TARGET SDL2_ttf::SDL2_ttf)
|
|||||||
endif()
|
endif()
|
||||||
find_package(TBB REQUIRED)
|
find_package(TBB REQUIRED)
|
||||||
|
|
||||||
if(ENABLE_LAUNCHER)
|
if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
|
||||||
# Widgets finds its own dependencies (QtGui and QtCore).
|
# Widgets finds its own dependencies (QtGui and QtCore).
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network)
|
||||||
@@ -355,6 +356,9 @@ add_subdirectory_with_folder("AI" AI)
|
|||||||
if(ENABLE_LAUNCHER)
|
if(ENABLE_LAUNCHER)
|
||||||
add_subdirectory(launcher)
|
add_subdirectory(launcher)
|
||||||
endif()
|
endif()
|
||||||
|
if(ENABLE_EDITOR)
|
||||||
|
add_subdirectory(mapeditor)
|
||||||
|
endif()
|
||||||
if(ENABLE_TEST)
|
if(ENABLE_TEST)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
@@ -389,7 +393,7 @@ if(WIN32)
|
|||||||
set(debug_postfix d)
|
set(debug_postfix d)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LAUNCHER)
|
if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
|
||||||
get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION)
|
get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION)
|
||||||
get_filename_component(Qtbin_folder ${QtCore_location} PATH)
|
get_filename_component(Qtbin_folder ${QtCore_location} PATH)
|
||||||
file(GLOB dep_files
|
file(GLOB dep_files
|
||||||
|
|||||||
107
mapeditor/CGameInfo.cpp
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* CGameInfo.cpp, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "StdInc.h"
|
||||||
|
#include "CGameInfo.h"
|
||||||
|
|
||||||
|
#include "../lib/VCMI_Lib.h"
|
||||||
|
|
||||||
|
const CGameInfo * CGI;
|
||||||
|
CClientState * CCS = nullptr;
|
||||||
|
CServerHandler * CSH;
|
||||||
|
|
||||||
|
|
||||||
|
CGameInfo::CGameInfo()
|
||||||
|
{
|
||||||
|
generaltexth = nullptr;
|
||||||
|
mh = nullptr;
|
||||||
|
townh = nullptr;
|
||||||
|
globalServices = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameInfo::setFromLib()
|
||||||
|
{
|
||||||
|
globalServices = VLC;
|
||||||
|
modh = VLC->modh;
|
||||||
|
generaltexth = VLC->generaltexth;
|
||||||
|
creh = VLC->creh;
|
||||||
|
townh = VLC->townh;
|
||||||
|
heroh = VLC->heroh;
|
||||||
|
objh = VLC->objh;
|
||||||
|
spellh = VLC->spellh;
|
||||||
|
skillh = VLC->skillh;
|
||||||
|
objtypeh = VLC->objtypeh;
|
||||||
|
battleFieldHandler = VLC->battlefieldsHandler;
|
||||||
|
obstacleHandler = VLC->obstacleHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ArtifactService * CGameInfo::artifacts() const
|
||||||
|
{
|
||||||
|
return globalServices->artifacts();
|
||||||
|
}
|
||||||
|
|
||||||
|
const BattleFieldService * CGameInfo::battlefields() const
|
||||||
|
{
|
||||||
|
return globalServices->battlefields();
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreatureService * CGameInfo::creatures() const
|
||||||
|
{
|
||||||
|
return globalServices->creatures();
|
||||||
|
}
|
||||||
|
|
||||||
|
const FactionService * CGameInfo::factions() const
|
||||||
|
{
|
||||||
|
return globalServices->factions();
|
||||||
|
}
|
||||||
|
|
||||||
|
const HeroClassService * CGameInfo::heroClasses() const
|
||||||
|
{
|
||||||
|
return globalServices->heroClasses();
|
||||||
|
}
|
||||||
|
|
||||||
|
const HeroTypeService * CGameInfo::heroTypes() const
|
||||||
|
{
|
||||||
|
return globalServices->heroTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
const scripting::Service * CGameInfo::scripts() const
|
||||||
|
{
|
||||||
|
return globalServices->scripts();
|
||||||
|
}
|
||||||
|
|
||||||
|
const spells::Service * CGameInfo::spells() const
|
||||||
|
{
|
||||||
|
return globalServices->spells();
|
||||||
|
}
|
||||||
|
|
||||||
|
const SkillService * CGameInfo::skills() const
|
||||||
|
{
|
||||||
|
return globalServices->skills();
|
||||||
|
}
|
||||||
|
|
||||||
|
const ObstacleService * CGameInfo::obstacles() const
|
||||||
|
{
|
||||||
|
return globalServices->obstacles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameInfo::updateEntity(Metatype metatype, int32_t index, const JsonNode & data)
|
||||||
|
{
|
||||||
|
logGlobal->error("CGameInfo::updateEntity call is not expected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
spells::effects::Registry * CGameInfo::spellEffects()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const spells::effects::Registry * CGameInfo::spellEffects() const
|
||||||
|
{
|
||||||
|
return globalServices->spellEffects();
|
||||||
|
}
|
||||||
93
mapeditor/CGameInfo.h
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* CGameInfo.h, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vcmi/Services.h>
|
||||||
|
|
||||||
|
#include "../lib/ConstTransitivePtr.h"
|
||||||
|
|
||||||
|
class CModHandler;
|
||||||
|
class CMapHandler;
|
||||||
|
class CHeroHandler;
|
||||||
|
class CCreatureHandler;
|
||||||
|
class CSpellHandler;
|
||||||
|
class CSkillHandler;
|
||||||
|
class CBuildingHandler;
|
||||||
|
class CObjectHandler;
|
||||||
|
class CSoundHandler;
|
||||||
|
class CMusicHandler;
|
||||||
|
class CObjectClassesHandler;
|
||||||
|
class CTownHandler;
|
||||||
|
class CGeneralTextHandler;
|
||||||
|
class CConsoleHandler;
|
||||||
|
class CCursorHandler;
|
||||||
|
class CGameState;
|
||||||
|
class IMainVideoPlayer;
|
||||||
|
class CServerHandler;
|
||||||
|
class BattleFieldHandler;
|
||||||
|
class ObstacleHandler;
|
||||||
|
|
||||||
|
class CMap;
|
||||||
|
|
||||||
|
|
||||||
|
//a class for non-mechanical client GUI classes
|
||||||
|
class CClientState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSoundHandler * soundh;
|
||||||
|
CMusicHandler * musich;
|
||||||
|
CConsoleHandler * consoleh;
|
||||||
|
CCursorHandler * curh;
|
||||||
|
IMainVideoPlayer * videoh;
|
||||||
|
};
|
||||||
|
extern CClientState * CCS;
|
||||||
|
|
||||||
|
/// CGameInfo class
|
||||||
|
/// for allowing different functions for accessing game informations
|
||||||
|
class CGameInfo : public Services
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const ArtifactService * artifacts() const override;
|
||||||
|
const CreatureService * creatures() const override;
|
||||||
|
const FactionService * factions() const override;
|
||||||
|
const HeroClassService * heroClasses() const override;
|
||||||
|
const HeroTypeService * heroTypes() const override;
|
||||||
|
const scripting::Service * scripts() const override;
|
||||||
|
const spells::Service * spells() const override;
|
||||||
|
const SkillService * skills() const override;
|
||||||
|
const BattleFieldService * battlefields() const override;
|
||||||
|
const ObstacleService * obstacles() const override;
|
||||||
|
|
||||||
|
void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) override;
|
||||||
|
|
||||||
|
const spells::effects::Registry * spellEffects() const override;
|
||||||
|
spells::effects::Registry * spellEffects() override;
|
||||||
|
|
||||||
|
|
||||||
|
ConstTransitivePtr<CModHandler> modh; //public?
|
||||||
|
ConstTransitivePtr<BattleFieldHandler> battleFieldHandler;
|
||||||
|
ConstTransitivePtr<CHeroHandler> heroh;
|
||||||
|
ConstTransitivePtr<CCreatureHandler> creh;
|
||||||
|
ConstTransitivePtr<CSpellHandler> spellh;
|
||||||
|
ConstTransitivePtr<CSkillHandler> skillh;
|
||||||
|
ConstTransitivePtr<CObjectHandler> objh;
|
||||||
|
ConstTransitivePtr<CObjectClassesHandler> objtypeh;
|
||||||
|
ConstTransitivePtr<ObstacleHandler> obstacleHandler;
|
||||||
|
CGeneralTextHandler * generaltexth;
|
||||||
|
CMapHandler * mh;
|
||||||
|
CTownHandler * townh;
|
||||||
|
|
||||||
|
void setFromLib();
|
||||||
|
|
||||||
|
CGameInfo();
|
||||||
|
private:
|
||||||
|
const Services * globalServices;
|
||||||
|
};
|
||||||
|
extern const CGameInfo* CGI;
|
||||||
87
mapeditor/CMakeLists.txt
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
set(editor_SRCS
|
||||||
|
StdInc.cpp
|
||||||
|
main.cpp
|
||||||
|
launcherdirs.cpp
|
||||||
|
jsonutils.cpp
|
||||||
|
mainwindow.cpp
|
||||||
|
CGameInfo.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(editor_HEADERS
|
||||||
|
StdInc.h
|
||||||
|
launcherdirs.h
|
||||||
|
jsonutils.h
|
||||||
|
mainwindow.h
|
||||||
|
CGameInfo.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(editor_FORMS
|
||||||
|
mainwindow.ui
|
||||||
|
)
|
||||||
|
|
||||||
|
assign_source_group(${editor_SRCS} ${editor_HEADERS} VCMI_launcher.rc)
|
||||||
|
|
||||||
|
# Tell CMake to run moc when necessary:
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
|
if(POLICY CMP0071)
|
||||||
|
cmake_policy(SET CMP0071 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# As moc files are generated in the binary dir, tell CMake
|
||||||
|
# to always look for includes there:
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
if(TARGET Qt6::Core)
|
||||||
|
qt_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
|
||||||
|
else()
|
||||||
|
qt5_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(editor_ICON VCMI_launcher.rc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(vcmieditor WIN32 ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set_target_properties(vcmieditor
|
||||||
|
PROPERTIES
|
||||||
|
OUTPUT_NAME "VCMI_mapeditor"
|
||||||
|
PROJECT_LABEL "VCMI_mapeditor"
|
||||||
|
)
|
||||||
|
|
||||||
|
# FIXME: Can't to get CMP0020 working with Vcpkg and CMake 3.8.2
|
||||||
|
# So far I tried:
|
||||||
|
# - cmake_minimum_required set to 2.8.11 globally and in this file
|
||||||
|
# - cmake_policy in all possible places
|
||||||
|
# - used NO_POLICY_SCOPE to make sure no other parts reset policies
|
||||||
|
# Still nothing worked, warning kept appearing and WinMain didn't link automatically
|
||||||
|
target_link_libraries(vcmieditor Qt${QT_VERSION_MAJOR}::WinMain)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
# This makes Xcode project prettier by moving vcmilauncher_autogen directory into vcmiclient subfolder
|
||||||
|
set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmieditor)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(vcmieditor vcmi Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
|
||||||
|
target_include_directories(vcmieditor
|
||||||
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
vcmi_set_output_dir(vcmieditor "")
|
||||||
|
enable_pch(vcmieditor)
|
||||||
|
|
||||||
|
# Copy to build directory for easier debugging
|
||||||
|
add_custom_command(TARGET vcmieditor POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/icons
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/mapeditor/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/icons
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS vcmieditor DESTINATION ${BIN_DIR})
|
||||||
|
# copy whole directory
|
||||||
|
install(DIRECTORY icons DESTINATION ${DATA_DIR}/mapeditor)
|
||||||
|
# Install icons and desktop file on Linux
|
||||||
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
|
install(FILES "vcmilauncher.desktop" DESTINATION share/applications)
|
||||||
|
endif()
|
||||||
1
mapeditor/StdInc.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "StdInc.h"
|
||||||
29
mapeditor/StdInc.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../Global.h"
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
inline QString pathToQString(const boost::filesystem::path & path)
|
||||||
|
{
|
||||||
|
#ifdef VCMI_WINDOWS
|
||||||
|
return QString::fromStdWString(path.wstring());
|
||||||
|
#else
|
||||||
|
return QString::fromStdString(path.string());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline boost::filesystem::path qstringToPath(const QString & path)
|
||||||
|
{
|
||||||
|
#ifdef VCMI_WINDOWS
|
||||||
|
return boost::filesystem::path(path.toStdWString());
|
||||||
|
#else
|
||||||
|
return boost::filesystem::path(path.toUtf8().data());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
110
mapeditor/VCMI_launcher.cbp
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="VCMI_launcher" />
|
||||||
|
<Option pch_mode="0" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug Win32">
|
||||||
|
<Option output="../VCMI_launcher" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option working_dir="../" />
|
||||||
|
<Option object_output="../obj/Launcher/Debug" />
|
||||||
|
<Option type="0" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-g" />
|
||||||
|
<Add option="-Og" />
|
||||||
|
</Compiler>
|
||||||
|
</Target>
|
||||||
|
<Target title="Release Win32">
|
||||||
|
<Option output="../VCMI_launcher" prefix_auto="1" extension_auto="1" />
|
||||||
|
<Option working_dir="../" />
|
||||||
|
<Option object_output="../obj/Launcher/Release" />
|
||||||
|
<Option type="0" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-O3" />
|
||||||
|
<Add option="-flto" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-s" />
|
||||||
|
<Add option="-flto" />
|
||||||
|
</Linker>
|
||||||
|
</Target>
|
||||||
|
</Build>
|
||||||
|
<Compiler>
|
||||||
|
<Add option="-Wextra" />
|
||||||
|
<Add option="-Wall" />
|
||||||
|
<Add option="-std=gnu++11" />
|
||||||
|
<Add option="-isystem $(#boost.include)" />
|
||||||
|
<Add option="-DBOOST_SYSTEM_NO_DEPRECATED" />
|
||||||
|
<Add option="-D_WIN32" />
|
||||||
|
<Add directory="." />
|
||||||
|
<Add directory="$(#qt.include)" />
|
||||||
|
<Add directory="$(#qt.include)/QtGui" />
|
||||||
|
<Add directory="$(#qt.include)/QtCore" />
|
||||||
|
<Add directory="$(#qt.include)/QtWidgets" />
|
||||||
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-lVCMI_lib" />
|
||||||
|
<Add option="-lQt5Core" />
|
||||||
|
<Add option="-lQt5Gui" />
|
||||||
|
<Add option="-lQt5Widgets" />
|
||||||
|
<Add option="-lQt5Network" />
|
||||||
|
<Add option="-lboost_filesystem$(#boost.libsuffix)" />
|
||||||
|
<Add option="-lboost_system$(#boost.libsuffix)" />
|
||||||
|
<Add directory="../" />
|
||||||
|
<Add directory="$(#qt.lib)" />
|
||||||
|
<Add directory="$(#boost.lib)" />
|
||||||
|
</Linker>
|
||||||
|
<Unit filename="StdInc.cpp">
|
||||||
|
<Option compile="0" />
|
||||||
|
<Option link="0" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="StdInc.h">
|
||||||
|
<Option compile="1" />
|
||||||
|
<Option weight="0" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="VCMI_launcher.rc">
|
||||||
|
<Option compilerVar="WINDRES" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="jsonutils.cpp" />
|
||||||
|
<Unit filename="jsonutils.h" />
|
||||||
|
<Unit filename="launcherdirs.cpp" />
|
||||||
|
<Unit filename="launcherdirs.h" />
|
||||||
|
<Unit filename="main.cpp" />
|
||||||
|
<Unit filename="mainwindow_moc.cpp" />
|
||||||
|
<Unit filename="mainwindow_moc.h" />
|
||||||
|
<Unit filename="mainwindow_moc.ui" />
|
||||||
|
<Unit filename="modManager/cdownloadmanager_moc.cpp" />
|
||||||
|
<Unit filename="modManager/cdownloadmanager_moc.h" />
|
||||||
|
<Unit filename="modManager/cmodlist.cpp" />
|
||||||
|
<Unit filename="modManager/cmodlist.h" />
|
||||||
|
<Unit filename="modManager/cmodlistmodel_moc.cpp" />
|
||||||
|
<Unit filename="modManager/cmodlistmodel_moc.h" />
|
||||||
|
<Unit filename="modManager/cmodlistview_moc.cpp" />
|
||||||
|
<Unit filename="modManager/cmodlistview_moc.h" />
|
||||||
|
<Unit filename="modManager/cmodlistview_moc.ui" />
|
||||||
|
<Unit filename="modManager/cmodmanager.cpp" />
|
||||||
|
<Unit filename="modManager/cmodmanager.h" />
|
||||||
|
<Unit filename="modManager/imageviewer_moc.cpp" />
|
||||||
|
<Unit filename="modManager/imageviewer_moc.h" />
|
||||||
|
<Unit filename="modManager/imageviewer_moc.ui" />
|
||||||
|
<Unit filename="modManager/qrc_cdownloadmanager_moc.cpp" />
|
||||||
|
<Unit filename="modManager/qrc_cmodlistmodel_moc.cpp" />
|
||||||
|
<Unit filename="modManager/qrc_cmodlistview_moc.cpp" />
|
||||||
|
<Unit filename="modManager/qrc_imageviewer_moc.cpp" />
|
||||||
|
<Unit filename="qrc_mainwindow_moc.cpp" />
|
||||||
|
<Unit filename="settingsView/csettingsview_moc.cpp" />
|
||||||
|
<Unit filename="settingsView/csettingsview_moc.h" />
|
||||||
|
<Unit filename="settingsView/csettingsview_moc.ui" />
|
||||||
|
<Unit filename="settingsView/qrc_csettingsview_moc.cpp" />
|
||||||
|
<Extensions>
|
||||||
|
<code_completion />
|
||||||
|
<envvars />
|
||||||
|
<debugger />
|
||||||
|
<lib_finder disable_auto="1" />
|
||||||
|
</Extensions>
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
||||||
BIN
mapeditor/VCMI_launcher.ico
Normal file
|
After Width: | Height: | Size: 31 KiB |
1
mapeditor/VCMI_launcher.rc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
IDI_ICON1 ICON "VCMI_launcher.ico"
|
||||||
BIN
mapeditor/icons/menu-game.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
mapeditor/icons/menu-mods.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
mapeditor/icons/menu-settings.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
mapeditor/icons/mod-delete.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
mapeditor/icons/mod-disabled.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
mapeditor/icons/mod-download.png
Normal file
|
After Width: | Height: | Size: 895 B |
BIN
mapeditor/icons/mod-enabled.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
mapeditor/icons/mod-update.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
125
mapeditor/jsonutils.cpp
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* jsonutils.cpp, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "StdInc.h"
|
||||||
|
#include "jsonutils.h"
|
||||||
|
#include "../lib/filesystem/FileStream.h"
|
||||||
|
|
||||||
|
static QVariantMap JsonToMap(const JsonMap & json)
|
||||||
|
{
|
||||||
|
QVariantMap map;
|
||||||
|
for(auto & entry : json)
|
||||||
|
{
|
||||||
|
map.insert(QString::fromUtf8(entry.first.c_str()), JsonUtils::toVariant(entry.second));
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QVariantList JsonToList(const JsonVector & json)
|
||||||
|
{
|
||||||
|
QVariantList list;
|
||||||
|
for(auto & entry : json)
|
||||||
|
{
|
||||||
|
list.push_back(JsonUtils::toVariant(entry));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static JsonVector VariantToList(QVariantList variant)
|
||||||
|
{
|
||||||
|
JsonVector vector;
|
||||||
|
for(auto & entry : variant)
|
||||||
|
{
|
||||||
|
vector.push_back(JsonUtils::toJson(entry));
|
||||||
|
}
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
static JsonMap VariantToMap(QVariantMap variant)
|
||||||
|
{
|
||||||
|
JsonMap map;
|
||||||
|
for(auto & entry : variant.toStdMap())
|
||||||
|
{
|
||||||
|
map[entry.first.toUtf8().data()] = JsonUtils::toJson(entry.second);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace JsonUtils
|
||||||
|
{
|
||||||
|
|
||||||
|
QVariant toVariant(const JsonNode & node)
|
||||||
|
{
|
||||||
|
switch(node.getType())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
case JsonNode::JsonType::DATA_NULL:
|
||||||
|
return QVariant();
|
||||||
|
break;
|
||||||
|
case JsonNode::JsonType::DATA_BOOL:
|
||||||
|
return QVariant(node.Bool());
|
||||||
|
break;
|
||||||
|
case JsonNode::JsonType::DATA_FLOAT:
|
||||||
|
return QVariant(node.Float());
|
||||||
|
break;
|
||||||
|
case JsonNode::JsonType::DATA_STRING:
|
||||||
|
return QVariant(QString::fromUtf8(node.String().c_str()));
|
||||||
|
break;
|
||||||
|
case JsonNode::JsonType::DATA_VECTOR:
|
||||||
|
return JsonToList(node.Vector());
|
||||||
|
break;
|
||||||
|
case JsonNode::JsonType::DATA_STRUCT:
|
||||||
|
return JsonToMap(node.Struct());
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant JsonFromFile(QString filename)
|
||||||
|
{
|
||||||
|
QFile file(filename);
|
||||||
|
file.open(QFile::ReadOnly);
|
||||||
|
auto data = file.readAll();
|
||||||
|
|
||||||
|
if(data.size() == 0)
|
||||||
|
{
|
||||||
|
logGlobal->error("Failed to open file %s", filename.toUtf8().data());
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JsonNode node(data.data(), data.size());
|
||||||
|
return toVariant(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonNode toJson(QVariant object)
|
||||||
|
{
|
||||||
|
JsonNode ret;
|
||||||
|
|
||||||
|
if(object.canConvert<QVariantMap>())
|
||||||
|
ret.Struct() = VariantToMap(object.toMap());
|
||||||
|
else if(object.canConvert<QVariantList>())
|
||||||
|
ret.Vector() = VariantToList(object.toList());
|
||||||
|
else if(object.userType() == QMetaType::QString)
|
||||||
|
ret.String() = object.toString().toUtf8().data();
|
||||||
|
else if(object.userType() == QMetaType::Bool)
|
||||||
|
ret.Bool() = object.toBool();
|
||||||
|
else if(object.canConvert<double>())
|
||||||
|
ret.Float() = object.toFloat();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JsonToFile(QString filename, QVariant object)
|
||||||
|
{
|
||||||
|
FileStream file(qstringToPath(filename), std::ios::out | std::ios_base::binary);
|
||||||
|
file << toJson(object).toJson();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
22
mapeditor/jsonutils.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* jsonutils.h, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
|
#include "../lib/JsonNode.h"
|
||||||
|
|
||||||
|
namespace JsonUtils
|
||||||
|
{
|
||||||
|
QVariant toVariant(const JsonNode & node);
|
||||||
|
QVariant JsonFromFile(QString filename);
|
||||||
|
|
||||||
|
JsonNode toJson(QVariant object);
|
||||||
|
void JsonToFile(QString filename, QVariant object);
|
||||||
|
}
|
||||||
36
mapeditor/launcherdirs.cpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* launcherdirs.cpp, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "StdInc.h"
|
||||||
|
#include "launcherdirs.h"
|
||||||
|
|
||||||
|
#include "../lib/VCMIDirs.h"
|
||||||
|
|
||||||
|
static CLauncherDirs launcherDirsGlobal;
|
||||||
|
|
||||||
|
CLauncherDirs::CLauncherDirs()
|
||||||
|
{
|
||||||
|
QDir().mkdir(downloadsPath());
|
||||||
|
QDir().mkdir(modsPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
CLauncherDirs & CLauncherDirs::get()
|
||||||
|
{
|
||||||
|
return launcherDirsGlobal;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CLauncherDirs::downloadsPath()
|
||||||
|
{
|
||||||
|
return pathToQString(VCMIDirs::get().userCachePath() / "downloads");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CLauncherDirs::modsPath()
|
||||||
|
{
|
||||||
|
return pathToQString(VCMIDirs::get().userDataPath() / "Mods");
|
||||||
|
}
|
||||||
22
mapeditor/launcherdirs.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* launcherdirs.h, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// similar to lib/VCMIDirs, controls where all launcher-related data will be stored
|
||||||
|
class CLauncherDirs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLauncherDirs();
|
||||||
|
|
||||||
|
static CLauncherDirs & get();
|
||||||
|
|
||||||
|
QString downloadsPath();
|
||||||
|
QString modsPath();
|
||||||
|
};
|
||||||
20
mapeditor/main.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* main.cpp, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <QApplication>
|
||||||
|
#include "StdInc.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
QApplication vcmieditor(argc, argv);
|
||||||
|
MainWindow mainWindow;
|
||||||
|
mainWindow.show();
|
||||||
|
return vcmieditor.exec();
|
||||||
|
}
|
||||||
95
mapeditor/mainwindow.cpp
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
#include <QApplication.h>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include "../lib/VCMIDirs.h"
|
||||||
|
#include "../lib/VCMI_Lib.h"
|
||||||
|
#include "../lib/logging/CBasicLogConfigurator.h"
|
||||||
|
#include "../lib/CConfigHandler.h"
|
||||||
|
#include "../lib/filesystem/Filesystem.h"
|
||||||
|
#include "../lib/GameConstants.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "CGameInfo.h"
|
||||||
|
|
||||||
|
static CBasicLogConfigurator * logConfig;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
loadDLLClasses();
|
||||||
|
const_cast<CGameInfo*>(CGI)->setFromLib();
|
||||||
|
logGlobal->info("Initializing VCMI_Lib");
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
QMainWindow(parent),
|
||||||
|
ui(new Ui::MainWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
//configure logging
|
||||||
|
const boost::filesystem::path logPath = VCMIDirs::get().userCachePath() / "VCMI_Editor_log.txt";
|
||||||
|
console = new CConsoleHandler();
|
||||||
|
logConfig = new CBasicLogConfigurator(logPath, console);
|
||||||
|
logConfig->configureDefault();
|
||||||
|
logGlobal->info("The log file will be saved to %s", logPath);
|
||||||
|
|
||||||
|
//init
|
||||||
|
preinitDLL(::console);
|
||||||
|
settings.init();
|
||||||
|
|
||||||
|
// Initialize logging based on settings
|
||||||
|
logConfig->configure();
|
||||||
|
logGlobal->debug("settings = %s", settings.toJsonNode().toJson());
|
||||||
|
|
||||||
|
// Some basic data validation to produce better error messages in cases of incorrect install
|
||||||
|
auto testFile = [](std::string filename, std::string message) -> bool
|
||||||
|
{
|
||||||
|
if (CResourceHandler::get()->existsResource(ResourceID(filename)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
logGlobal->error("Error: %s was not found!", message);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!testFile("DATA/HELP.TXT", "Heroes III data") ||
|
||||||
|
!testFile("MODS/VCMI/MOD.JSON", "VCMI data"))
|
||||||
|
{
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.init();
|
||||||
|
logGlobal->info("Loading settings");
|
||||||
|
|
||||||
|
CGI = new CGameInfo(); //contains all global informations about game (texts, lodHandlers, map handler etc.)
|
||||||
|
init();
|
||||||
|
|
||||||
|
|
||||||
|
if(!testFile("DATA/new-menu/Background.png", "Cannot find file"))
|
||||||
|
{
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
//now let's try to draw
|
||||||
|
auto resPath = *CResourceHandler::get()->getResourceName(ResourceID("DATA/new-menu/Background.png"));
|
||||||
|
|
||||||
|
scene = new QGraphicsScene(this);
|
||||||
|
ui->graphicsView->setScene(scene);
|
||||||
|
scene->addPixmap(QPixmap(QString::fromStdString(resPath.native())));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionOpen_triggered()
|
||||||
|
{
|
||||||
|
auto fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QString::fromStdString(VCMIDirs::get().userCachePath().native()), tr("Homm3 Files (*.vmap *.h3m)"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
28
mapeditor/mainwindow.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_actionOpen_triggered();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
|
QGraphicsScene * scene;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
||||||
61
mapeditor/mainwindow.ui
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1055</width>
|
||||||
|
<height>737</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGraphicsView" name="graphicsView"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1055</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuFile">
|
||||||
|
<property name="title">
|
||||||
|
<string>File</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionOpen"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuFile"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="actionOpen"/>
|
||||||
|
</widget>
|
||||||
|
<action name="actionOpen">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||