Merge remote-tracking branch 'Ancurio-MKXP/master'

This commit is contained in:
Vinyl Darkscratch 2019-04-21 03:45:13 -07:00
commit 62b5cda85a
No known key found for this signature in database
GPG key ID: 0AF19E90D93375CA
5 changed files with 463 additions and 298 deletions

View file

@ -28,6 +28,7 @@ set(MAIN_HEADERS
src/flashable.h src/flashable.h
src/font.h src/font.h
src/input.h src/input.h
src/iniconfig.h
src/plane.h src/plane.h
src/scene.h src/scene.h
src/sprite.h src/sprite.h
@ -87,6 +88,7 @@ set(MAIN_SOURCE
src/filesystem.cpp src/filesystem.cpp
src/font.cpp src/font.cpp
src/input.cpp src/input.cpp
src/iniconfig.cpp
src/plane.cpp src/plane.cpp
src/scene.cpp src/scene.cpp
src/sprite.cpp src/sprite.cpp

598
mkxp.pro
View file

@ -1,298 +1,300 @@
TEMPLATE = app TEMPLATE = app
QT = QT =
TARGET = OneShot TARGET = OneShot
DEPENDPATH += src shader assets DEPENDPATH += src shader assets
INCLUDEPATH += . src INCLUDEPATH += . src
CONFIG -= qt CONFIG -= qt
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
CONFIG(release, debug|release): DEFINES += NDEBUG STEAM CONFIG(release, debug|release): DEFINES += NDEBUG STEAM
isEmpty(BINDING) { isEmpty(BINDING) {
BINDING = MRI BINDING = MRI
} }
contains(BINDING, MRI) { contains(BINDING, MRI) {
contains(_HAVE_BINDING, YES) { contains(_HAVE_BINDING, YES) {
error("Only one binding may be selected") error("Only one binding may be selected")
} }
_HAVE_BINDING = YES _HAVE_BINDING = YES
CONFIG += BINDING_MRI CONFIG += BINDING_MRI
} }
contains(BINDING, NULL) { contains(BINDING, NULL) {
contains(_HAVE_BINDING, YES) { contains(_HAVE_BINDING, YES) {
error("Only one binding may be selected") error("Only one binding may be selected")
} }
_HAVE_BINDING = YES _HAVE_BINDING = YES
CONFIG += BINDING_NULL CONFIG += BINDING_NULL
} }
PKGCONFIG = sigc++-2.0 pixman-1 zlib sdl2 SDL2_image SDL2_ttf openal SDL_sound vorbisfile PKGCONFIG = sigc++-2.0 pixman-1 zlib sdl2 SDL2_image SDL2_ttf openal SDL_sound vorbisfile
unix { unix {
CONFIG += c++11 CONFIG += c++11
PKGCONFIG += physfs PKGCONFIG += physfs
LIBS += -ldl LIBS += -ldl
macx: { macx: {
INCLUDEPATH += $$QMAKE_MAC_SDK_PATH/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers /usr/local/include INCLUDEPATH += $$QMAKE_MAC_SDK_PATH/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers /usr/local/include
LIBS += -framework OpenAL -framework AppKit LIBS += -framework OpenAL -framework AppKit
QMAKE_LFLAGS += -L/usr/local/lib -L/usr/local/opt/ruby/lib -L/usr/local/opt/openal-soft/lib QMAKE_LFLAGS += -L/usr/local/lib -L/usr/local/opt/ruby/lib -L/usr/local/opt/openal-soft/lib
HEADERS += src/mac-desktop.h HEADERS += src/mac-desktop.h
SOURCES += src/mac-desktop.mm SOURCES += src/mac-desktop.mm
} }
!macx: { !macx: {
QMAKE_CXXFLAGS += -g QMAKE_CXXFLAGS += -g
PKGCONFIG += gtk+-3.0 gdk-3.0 libxfconf-0 PKGCONFIG += gtk+-3.0 gdk-3.0 libxfconf-0
INCLUDEPATH += /usr/include/AL /usr/local/include/AL INCLUDEPATH += /usr/include/AL /usr/local/include/AL
LIBS += -lX11 LIBS += -lX11
} }
} }
win32 { win32 {
QMAKE_CXXFLAGS += -std=gnu++11 QMAKE_CXXFLAGS += -std=gnu++11
QMAKE_LFLAGS += -std=gnu++11 QMAKE_LFLAGS += -std=gnu++11
PKGCONFIG += freetype2 PKGCONFIG += freetype2
LIBS += -lphysfs -lsecur32 -lwinmm LIBS += -lphysfs -lsecur32 -lwinmm
release { release {
RC_FILE = assets/resources.rc RC_FILE = assets/resources.rc
} }
} }
# Deal with boost paths... # Deal with boost paths...
isEmpty(BOOST_I) { isEmpty(BOOST_I) {
BOOST_I = $$(BOOST_I) BOOST_I = $$(BOOST_I)
} }
isEmpty(BOOST_I) {} isEmpty(BOOST_I) {}
else { else {
INCLUDEPATH += $$BOOST_I INCLUDEPATH += $$BOOST_I
} }
isEmpty(BOOST_L) { isEmpty(BOOST_L) {
BOOST_L = $$(BOOST_L) BOOST_L = $$(BOOST_L)
} }
isEmpty(BOOST_L) {} isEmpty(BOOST_L) {}
else { else {
LIBS += -L$$BOOST_L LIBS += -L$$BOOST_L
} }
isEmpty(BOOST_LIB_SUFFIX) { isEmpty(BOOST_LIB_SUFFIX) {
BOOST_LIB_SUFFIX = $$(BOOST_LIB_SUFFIX) BOOST_LIB_SUFFIX = $$(BOOST_LIB_SUFFIX)
} }
LIBS += -lboost_program_options$$BOOST_LIB_SUFFIX LIBS += -lboost_program_options$$BOOST_LIB_SUFFIX
# Input # Input
HEADERS += \ HEADERS += \
src/quadarray.h \ src/quadarray.h \
src/audio.h \ src/audio.h \
src/binding.h \ src/binding.h \
src/bitmap.h \ src/bitmap.h \
src/disposable.h \ src/disposable.h \
src/etc.h \ src/etc.h \
src/etc-internal.h \ src/etc-internal.h \
src/eventthread.h \ src/eventthread.h \
src/flashable.h \ src/flashable.h \
src/font.h \ src/font.h \
src/input.h \ src/input.h \
src/plane.h \ src/iniconfig.h \
src/scene.h \ src/plane.h \
src/sprite.h \ src/scene.h \
src/table.h \ src/sprite.h \
src/texpool.h \ src/table.h \
src/tilequad.h \ src/texpool.h \
src/transform.h \ src/tilequad.h \
src/viewport.h \ src/transform.h \
src/window.h \ src/viewport.h \
src/serializable.h \ src/window.h \
src/shader.h \ src/serializable.h \
src/glstate.h \ src/shader.h \
src/quad.h \ src/glstate.h \
src/tilemap.h \ src/quad.h \
src/tilemap-common.h \ src/tilemap.h \
src/graphics.h \ src/tilemap-common.h \
src/gl-debug.h \ src/graphics.h \
src/global-ibo.h \ src/gl-debug.h \
src/exception.h \ src/global-ibo.h \
src/filesystem.h \ src/exception.h \
src/serial-util.h \ src/filesystem.h \
src/intrulist.h \ src/serial-util.h \
src/binding.h \ src/intrulist.h \
src/gl-util.h \ src/binding.h \
src/util.h \ src/gl-util.h \
src/config.h \ src/util.h \
src/settingsmenu.h \ src/config.h \
src/keybindings.h \ src/settingsmenu.h \
src/tileatlas.h \ src/keybindings.h \
src/sharedstate.h \ src/tileatlas.h \
src/al-util.h \ src/sharedstate.h \
src/boost-hash.h \ src/al-util.h \
src/debugwriter.h \ src/boost-hash.h \
src/gl-fun.h \ src/debugwriter.h \
src/gl-meta.h \ src/gl-fun.h \
src/vertex.h \ src/gl-meta.h \
src/soundemitter.h \ src/vertex.h \
src/aldatasource.h \ src/soundemitter.h \
src/alstream.h \ src/aldatasource.h \
src/audiostream.h \ src/alstream.h \
src/rgssad.h \ src/audiostream.h \
src/sdl-util.h \ src/rgssad.h \
src/oneshot.h \ src/sdl-util.h \
src/pipe.h \ src/oneshot.h \
chromasdk/RzChromaSDKDefines.h \ src/pipe.h \
chromasdk/RzChromaSDKTypes.h \ chromasdk/RzChromaSDKDefines.h \
chromasdk/RzErrors.h \ chromasdk/RzChromaSDKTypes.h \
chromasdk/ChromaApi.h \ chromasdk/RzErrors.h \
src/i18n.h chromasdk/ChromaApi.h \
src/i18n.h
SOURCES += \
src/main.cpp \ SOURCES += \
src/audio.cpp \ src/main.cpp \
src/bitmap.cpp \ src/audio.cpp \
src/eventthread.cpp \ src/bitmap.cpp \
src/filesystem.cpp \ src/eventthread.cpp \
src/font.cpp \ src/filesystem.cpp \
src/input.cpp \ src/font.cpp \
src/plane.cpp \ src/input.cpp \
src/scene.cpp \ src/iniconfig.cpp \
src/sprite.cpp \ src/plane.cpp \
src/table.cpp \ src/scene.cpp \
src/tilequad.cpp \ src/sprite.cpp \
src/viewport.cpp \ src/table.cpp \
src/window.cpp \ src/tilequad.cpp \
src/texpool.cpp \ src/viewport.cpp \
src/shader.cpp \ src/window.cpp \
src/glstate.cpp \ src/texpool.cpp \
src/tilemap.cpp \ src/shader.cpp \
src/autotiles.cpp \ src/glstate.cpp \
src/graphics.cpp \ src/tilemap.cpp \
src/gl-debug.cpp \ src/autotiles.cpp \
src/etc.cpp \ src/graphics.cpp \
src/config.cpp \ src/gl-debug.cpp \
src/settingsmenu.cpp \ src/etc.cpp \
src/keybindings.cpp \ src/config.cpp \
src/tileatlas.cpp \ src/settingsmenu.cpp \
src/sharedstate.cpp \ src/keybindings.cpp \
src/gl-fun.cpp \ src/tileatlas.cpp \
src/gl-meta.cpp \ src/sharedstate.cpp \
src/vertex.cpp \ src/gl-fun.cpp \
src/soundemitter.cpp \ src/gl-meta.cpp \
src/sdlsoundsource.cpp \ src/vertex.cpp \
src/alstream.cpp \ src/soundemitter.cpp \
src/audiostream.cpp \ src/sdlsoundsource.cpp \
src/rgssad.cpp \ src/alstream.cpp \
src/vorbissource.cpp \ src/audiostream.cpp \
src/oneshot.cpp \ src/rgssad.cpp \
src/screen.cpp \ src/vorbissource.cpp \
src/i18n.cpp src/oneshot.cpp \
src/screen.cpp \
CONFIG(release, debug|release): { src/i18n.cpp
HEADERS += src/steam.h steamshim/steamshim_child.h
SOURCES += src/steam.cpp steamshim/steamshim_child.c CONFIG(release, debug|release): {
} HEADERS += src/steam.h steamshim/steamshim_child.h
SOURCES += src/steam.cpp steamshim/steamshim_child.c
EMBED = \ }
shader/common.h \
shader/transSimple.frag \ EMBED = \
shader/trans.frag \ shader/common.h \
shader/hue.frag \ shader/transSimple.frag \
shader/sprite.frag \ shader/trans.frag \
shader/plane.frag \ shader/hue.frag \
shader/gray.frag \ shader/sprite.frag \
shader/bitmapBlit.frag \ shader/plane.frag \
shader/flatColor.frag \ shader/gray.frag \
shader/simple.frag \ shader/bitmapBlit.frag \
shader/simpleColor.frag \ shader/flatColor.frag \
shader/simpleAlpha.frag \ shader/simple.frag \
shader/simpleAlphaUni.frag \ shader/simpleColor.frag \
shader/flashMap.frag \ shader/simpleAlpha.frag \
shader/obscured.frag \ shader/simpleAlphaUni.frag \
shader/minimal.vert \ shader/flashMap.frag \
shader/simple.vert \ shader/obscured.frag \
shader/simpleColor.vert \ shader/minimal.vert \
shader/sprite.vert \ shader/simple.vert \
shader/tilemap.vert \ shader/simpleColor.vert \
shader/blur.frag \ shader/sprite.vert \
shader/blurH.vert \ shader/tilemap.vert \
shader/blurV.vert \ shader/blur.frag \
shader/simpleMatrix.vert \ shader/blurH.vert \
assets/icon.png \ shader/blurV.vert \
assets/gamecontrollerdb.txt shader/simpleMatrix.vert \
assets/icon.png \
defineReplace(xxdOutput) { assets/gamecontrollerdb.txt
return($$basename(1).xxd)
} defineReplace(xxdOutput) {
return($$basename(1).xxd)
# xxd }
xxd.output_function = xxdOutput
xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT} # xxd
xxd.depends = $$EMBED xxd.output_function = xxdOutput
xxd.input = EMBED xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}
xxd.variable_out = HEADERS xxd.depends = $$EMBED
xxd.input = EMBED
QMAKE_EXTRA_COMPILERS += xxd xxd.variable_out = HEADERS
QMAKE_EXTRA_COMPILERS += xxd
BINDING_NULL {
SOURCES += binding-null/binding-null.cpp
} BINDING_NULL {
SOURCES += binding-null/binding-null.cpp
BINDING_MRI { }
isEmpty(MRIVERSION) {
MRIVERSION = 2.3 BINDING_MRI {
} isEmpty(MRIVERSION) {
MRIVERSION = 2.3
PKGCONFIG += ruby-$$MRIVERSION }
DEFINES += BINDING_MRI
PKGCONFIG += ruby-$$MRIVERSION
# EMBED2 = binding-mri/module_rpg.rb DEFINES += BINDING_MRI
# xxdp.output = ${QMAKE_FILE_NAME}.xxd
# xxdp.commands = xxd+/xxd+ ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} --string # EMBED2 = binding-mri/module_rpg.rb
# xxdp.depends = $$EMBED2 # xxdp.output = ${QMAKE_FILE_NAME}.xxd
# xxdp.input = EMBED2 # xxdp.commands = xxd+/xxd+ ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} --string
# xxdp.variable_out = HEADERS # xxdp.depends = $$EMBED2
# QMAKE_EXTRA_COMPILERS += xxdp # xxdp.input = EMBED2
# xxdp.variable_out = HEADERS
HEADERS += \ # QMAKE_EXTRA_COMPILERS += xxdp
binding-mri/binding-util.h \
binding-mri/binding-types.h \ HEADERS += \
binding-mri/serializable-binding.h \ binding-mri/binding-util.h \
binding-mri/disposable-binding.h \ binding-mri/binding-types.h \
binding-mri/sceneelement-binding.h \ binding-mri/serializable-binding.h \
binding-mri/viewportelement-binding.h \ binding-mri/disposable-binding.h \
binding-mri/flashable-binding.h \ binding-mri/sceneelement-binding.h \
binding-mri/journal-binding.h binding-mri/viewportelement-binding.h \
binding-mri/flashable-binding.h \
SOURCES += \ binding-mri/journal-binding.h
binding-mri/binding-mri.cpp \
binding-mri/binding-util.cpp \ SOURCES += \
binding-mri/table-binding.cpp \ binding-mri/binding-mri.cpp \
binding-mri/etc-binding.cpp \ binding-mri/binding-util.cpp \
binding-mri/bitmap-binding.cpp \ binding-mri/table-binding.cpp \
binding-mri/font-binding.cpp \ binding-mri/etc-binding.cpp \
binding-mri/graphics-binding.cpp \ binding-mri/bitmap-binding.cpp \
binding-mri/input-binding.cpp \ binding-mri/font-binding.cpp \
binding-mri/sprite-binding.cpp \ binding-mri/graphics-binding.cpp \
binding-mri/viewport-binding.cpp \ binding-mri/input-binding.cpp \
binding-mri/plane-binding.cpp \ binding-mri/sprite-binding.cpp \
binding-mri/window-binding.cpp \ binding-mri/viewport-binding.cpp \
binding-mri/tilemap-binding.cpp \ binding-mri/plane-binding.cpp \
binding-mri/audio-binding.cpp \ binding-mri/window-binding.cpp \
binding-mri/module_rpg.cpp \ binding-mri/tilemap-binding.cpp \
binding-mri/filesystem-binding.cpp \ binding-mri/audio-binding.cpp \
binding-mri/oneshot-binding.cpp \ binding-mri/module_rpg.cpp \
binding-mri/steam-binding.cpp \ binding-mri/filesystem-binding.cpp \
binding-mri/wallpaper-binding.cpp \ binding-mri/oneshot-binding.cpp \
binding-mri/journal-binding.cpp \ binding-mri/steam-binding.cpp \
binding-mri/chroma-binding.cpp \ binding-mri/wallpaper-binding.cpp \
binding-mri/niko-binding.cpp binding-mri/journal-binding.cpp \
} binding-mri/chroma-binding.cpp \
binding-mri/niko-binding.cpp
OTHER_FILES += $$EMBED }
OTHER_FILES += $$EMBED

View file

@ -34,6 +34,7 @@
#include "debugwriter.h" #include "debugwriter.h"
#include "util.h" #include "util.h"
#include "sdl-util.h" #include "sdl-util.h"
#include "iniconfig.h"
namespace std namespace std
{ {

114
src/iniconfig.cpp Normal file
View file

@ -0,0 +1,114 @@
#include "iniconfig.h"
#include <algorithm>
std::string toLowerCase(const std::string& str)
{
std::string lower = str;
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
return lower;
}
std::string trim(const std::string& str, const std::string& chars = "\t\n\v\f\r ")
{
std::string trimmed = str;
trimmed.erase(trimmed.find_last_not_of(chars) + 1);
trimmed.erase(0, trimmed.find_first_not_of(chars));
return trimmed;
}
INIConfiguration::Section::Section (const std::string& sname) : m_Name (sname), m_PropertyMap()
{
}
bool INIConfiguration::Section::getStringProperty (const std::string& name, std::string& outPropStr) const
{
try
{
outPropStr = m_PropertyMap.at(toLowerCase(name)).m_Value;
return true;
}
catch (std::out_of_range& oorexcept)
{
return false;
}
}
bool INIConfiguration::load (std::istream& is)
{
if (!is.good())
{
return false;
}
std::string currSectionName;
std::string line;
std::getline (is, line);
while (!is.eof() && !is.bad())
{
if (line[0] == '[')
{
currSectionName = line.substr (1, line.find_last_of (']') - 1);
}
else if (line[0] != '#' && line.length() > 2)
{
int crloc = line.length() - 1;
if (crloc >= 0 && line[crloc] == '\r') //check for Windows-style newline
line.resize (crloc); //and correct
size_t equalsPos = line.find_first_of ("=");
if (equalsPos != std::string::npos)
{
std::string key = line.substr (0, equalsPos);
std::string val = line.substr (equalsPos + 1);
addProperty (currSectionName, key , val);
}
}
std::getline (is, line);
}
if (is.bad())
{
return false;
}
return true;
}
std::string INIConfiguration::getStringProperty(const std::string& sname, const std::string& name, const std::string& def) const
{
auto sectionIt = m_SectionMap.find(toLowerCase(sname));
if (sectionIt != m_SectionMap.end())
{
std::string prop;
if(sectionIt->second.getStringProperty(name, prop))
{
return prop;
}
}
return def;
}
void INIConfiguration::addProperty (const std::string& sname, const std::string& name, const std::string& val)
{
if (m_SectionMap.find (toLowerCase(sname)) == m_SectionMap.end())
{
m_SectionMap.emplace (toLowerCase(sname), Section (sname));
}
Section::Property p;
p.m_Name = trim(name);
p.m_Value = trim(val);
m_SectionMap.at (toLowerCase(sname)).m_PropertyMap[toLowerCase(p.m_Name)] = p;
}

46
src/iniconfig.h Normal file
View file

@ -0,0 +1,46 @@
#ifndef INICONFIG_H
#define INICONFIG_H
#include <iostream>
#include <map>
class INIConfiguration
{
class Section
{
friend class INIConfiguration;
struct Property
{
std::string m_Name;
std::string m_Value;
};
typedef std::map<std::string, Property> property_map;
public:
Section (const Section& s) = default;
Section (Section&& s) = default;
bool getStringProperty (const std::string& name, std::string& outPropStr) const;
private:
explicit Section (const std::string& name);
std::string m_Name;
property_map m_PropertyMap;
};
typedef std::map<std::string, Section> section_map;
public:
bool load (std::istream& inStream);
std::string getStringProperty(const std::string& sname, const std::string& name, const std::string& def = "") const;
protected:
void addProperty (const std::string& sname, const std::string& name, const std::string& val);
private:
section_map m_SectionMap;
};
#endif // INICONFIG_H