From 057aade18b6e0fc7868564ebb03eba18f3cb5348 Mon Sep 17 00:00:00 2001 From: ultra Date: Tue, 11 Oct 2016 22:56:28 -0400 Subject: [PATCH] Get it building and launching something --- SConstruct | 2 +- rsrc/SConscript | 5 +- src/SConscript | 6 +- src/boe.menus.linux.cpp | 64 ++++++++++++++ src/tools/SConscript | 3 + src/tools/cursors.linux.cpp | 20 +++++ src/tools/prefs.hpp | 1 + src/tools/winutil.linux.cpp | 163 ++++++++++++++++++++++++++++++++++++ 8 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 src/boe.menus.linux.cpp create mode 100644 src/tools/cursors.linux.cpp create mode 100644 src/tools/winutil.linux.cpp diff --git a/SConstruct b/SConstruct index 22d3eeb2..3a9f83fa 100644 --- a/SConstruct +++ b/SConstruct @@ -302,7 +302,7 @@ Export("env platform") common_classes, party_classes = SConscript("build/obj/classes/SConscript") tools = SConscript("build/obj/tools/SConscript") dlog_util = SConscript("build/obj/dialogxml/SConscript") -common_sources = common_classes + dlog_util + tools +common_sources = dlog_util + tools + common_classes install_dir = "#build/Blades of Exile" Export("install_dir party_classes common_sources") diff --git a/rsrc/SConscript b/rsrc/SConscript index 974eb9b3..8c9bcb04 100644 --- a/rsrc/SConscript +++ b/rsrc/SConscript @@ -2,6 +2,7 @@ from __future__ import print_function import os.path as path import subprocess +import os Import("env platform data_dir install_dir") @@ -30,7 +31,9 @@ env.Install(path.join(install_dir, "Blades of Exile Base"), Glob("Blades of Exil have_xmllint = False -if ((str(platform) != "win32" and subprocess.call(['which', '-s', 'xmllint']) == 0) or +nulldev = open(os.devnull, 'w') + +if ((str(platform) != "win32" and subprocess.call(['which', 'xmllint'], stdout=nulldev, stderr=nulldev) == 0) or (str(platform) == "win32" and subprocess.call(['where', '/Q', 'xmllint'])) == 0): have_xmllint = True xmllint_command = ('xmllint', '--nonet', '--noout', '--schema', '../schemas/dialog.xsd') diff --git a/src/SConscript b/src/SConscript index 9f91c6b5..30916eb4 100644 --- a/src/SConscript +++ b/src/SConscript @@ -34,8 +34,12 @@ elif str(platform) == "win32": boe.menus.win.cpp """)) game_sources.append(env.RES('#build/obj/BladesOfExile.res', '#rsrc/menus/BladesOfExile.rc')) +elif str(platform) == "posix": + game_sources.extend(Split(""" + boe.menus.linux.cpp + """)) -boe = env.Program("#build/bin/Blades of Exile", game_sources + common_sources + party_classes) +boe = env.Program("#build/bin/Blades of Exile", game_sources + party_classes + common_sources) if str(platform) == "darwin": boe_info = { diff --git a/src/boe.menus.linux.cpp b/src/boe.menus.linux.cpp new file mode 100644 index 00000000..5ce5ccf3 --- /dev/null +++ b/src/boe.menus.linux.cpp @@ -0,0 +1,64 @@ + +#include "boe.menus.hpp" +#include +#include +#include +#include "universe.hpp" +#include "boe.party.hpp" +#include "boe.infodlg.hpp" +#include "boe.consts.hpp" +#include "spell.hpp" +#include "winutil.hpp" + +// This is the index of each menu on the menubar +enum { + FILE_MENU_POS = 0, + OPT_MENU_POS = 1, + ACT_MENU_POS = 2, + MONST_MENU_POS = 3, + MAGE_MENU_POS = 4, + PRIEST_MENU_POS = 5, + LIB_MENU_POS = 6, + HELP_MENU_POS = 7, +}; + +extern short on_spell_menu[2][62]; +extern short on_monst_menu[256]; +extern bool party_in_memory; +extern cUniverse univ; +extern eGameMode overall_mode; +extern sf::RenderWindow mainPtr; +std::map menuChoices; + +void init_menubar() { +} + +void adjust_monst_menu() { +} + +void init_spell_menus() { +} + +void adjust_spell_menus() { +} + +void menu_activate() { +} + +void hideMenuBar() { +} + +void showMenuBar() { +} + +#include "cursors.hpp" + +#include "fileio.hpp" +#include "boe.graphics.hpp" +#include "boe.actions.hpp" +#include "boe.fileio.hpp" + +extern bool ae_loading, finished_init; +void set_up_apple_events(int argc, char* argv[]) { + +} diff --git a/src/tools/SConscript b/src/tools/SConscript index 32da80e7..a388f978 100644 --- a/src/tools/SConscript +++ b/src/tools/SConscript @@ -20,6 +20,9 @@ if str(platform) == "darwin": tools.extend(Glob("*.mac.*")) elif str(platform) == "win32": tools.extend(Glob("*.win.cpp")) +elif str(platform) == "posix": + tools.extend(Glob("*.linux.cpp")) + tools.append("prefs.win.cpp") tools_obj = env.StaticLibrary("#build/lib/tools", tools) diff --git a/src/tools/cursors.linux.cpp b/src/tools/cursors.linux.cpp new file mode 100644 index 00000000..ee52cda0 --- /dev/null +++ b/src/tools/cursors.linux.cpp @@ -0,0 +1,20 @@ + +#include "cursors.hpp" + +Cursor::Cursor(fs::path imgPath, float hotSpotX, float hotSpotY) { +} + +Cursor::~Cursor() { +} + +void Cursor::apply() { +} + +void obscureCursor() { +} + +void set_cursor(cursor_type which_c) { +} + +void restore_cursor() { +} diff --git a/src/tools/prefs.hpp b/src/tools/prefs.hpp index 4296c51b..30a6b837 100644 --- a/src/tools/prefs.hpp +++ b/src/tools/prefs.hpp @@ -11,6 +11,7 @@ #include #include +#include void set_pref(std::string keypath, bool value); bool get_bool_pref(std::string keypath, bool fallback = false); diff --git a/src/tools/winutil.linux.cpp b/src/tools/winutil.linux.cpp new file mode 100644 index 00000000..95170c5c --- /dev/null +++ b/src/tools/winutil.linux.cpp @@ -0,0 +1,163 @@ + +#include "winutil.hpp" +#include +#include +#include +#include + +extern sf::RenderWindow mainPtr; + +// TODO: I'm sure there's a better way to do this (maybe one that's keyboard layout agnostic) +// The proper way would involve use of the TextEntered event +char keyToChar(sf::Keyboard::Key key, bool isShift) { + using kb = sf::Keyboard; + switch(key) { + case kb::A: return isShift ? 'A' : 'a'; + case kb::B: return isShift ? 'B' : 'b'; + case kb::C: return isShift ? 'C' : 'c'; + case kb::D: return isShift ? 'D' : 'd'; + case kb::E: return isShift ? 'E' : 'e'; + case kb::F: return isShift ? 'F' : 'f'; + case kb::G: return isShift ? 'G' : 'g'; + case kb::H: return isShift ? 'H' : 'h'; + case kb::I: return isShift ? 'I' : 'i'; + case kb::J: return isShift ? 'J' : 'j'; + case kb::K: return isShift ? 'K' : 'k'; + case kb::L: return isShift ? 'L' : 'l'; + case kb::M: return isShift ? 'M' : 'm'; + case kb::N: return isShift ? 'N' : 'n'; + case kb::O: return isShift ? 'O' : 'o'; + case kb::P: return isShift ? 'P' : 'p'; + case kb::Q: return isShift ? 'Q' : 'q'; + case kb::R: return isShift ? 'R' : 'r'; + case kb::S: return isShift ? 'S' : 's'; + case kb::T: return isShift ? 'T' : 't'; + case kb::U: return isShift ? 'U' : 'u'; + case kb::V: return isShift ? 'V' : 'v'; + case kb::W: return isShift ? 'W' : 'w'; + case kb::X: return isShift ? 'X' : 'x'; + case kb::Y: return isShift ? 'Y' : 'y'; + case kb::Z: return isShift ? 'Z' : 'z'; + case kb::Num1: return isShift ? '!' : '1'; + case kb::Num2: return isShift ? '@' : '2'; + case kb::Num3: return isShift ? '#' : '3'; + case kb::Num4: return isShift ? '$' : '4'; + case kb::Num5: return isShift ? '%' : '5'; + case kb::Num6: return isShift ? '^' : '6'; + case kb::Num7: return isShift ? '&' : '7'; + case kb::Num8: return isShift ? '*' : '8'; + case kb::Num9: return isShift ? '(' : '9'; + case kb::Num0: return isShift ? ')' : '0'; + case kb::Tilde: return isShift ? '~' : '`'; + case kb::Dash: return isShift ? '_' : '-'; + case kb::Equal: return isShift ? '+' : '='; + case kb::LBracket: return isShift ? '{' : '['; + case kb::RBracket: return isShift ? '}' : ']'; + case kb::SemiColon: return isShift ? ':' : ';'; + case kb::Quote: return isShift ? '"' : '\''; + case kb::Comma: return isShift ? '<' : ','; + case kb::Period: return isShift ? '>' : '.'; + case kb::Slash: return isShift ? '?' : '/'; + case kb::BackSlash: return isShift ? '|' : '\\'; + case kb::Tab: return '\t'; + case kb::Space: return ' '; + case kb::Return: return '\n'; + case kb::BackSpace: return '\b'; + case kb::Delete: return '\x7f'; + case kb::Numpad0: return '0'; + case kb::Numpad1: return '1'; + case kb::Numpad2: return '2'; + case kb::Numpad3: return '3'; + case kb::Numpad4: return '4'; + case kb::Numpad5: return '5'; + case kb::Numpad6: return '6'; + case kb::Numpad7: return '7'; + case kb::Numpad8: return '8'; + case kb::Numpad9: return '9'; + // TODO: Should have Equal here, but SFML doesn't distinguish between normal and keybad equal :/ + // Ditto for the decimal point. + case kb::Divide: return '/'; + case kb::Multiply: return '*'; + case kb::Subtract: return '-'; + case kb::Add: return '+'; + default: break; + } + return 0; +} + +std::string get_os_version() { + return "Microsoft Windows XP"; +} + +void makeFrontWindow(sf::Window& win) { +} + +void setWindowFloating(sf::Window& win, bool floating) { +} + +void init_fileio() { +} + +fs::path nav_get_party() { + return ""; +} + +fs::path nav_put_party(fs::path def) { + return ""; +} + +fs::path nav_get_scenario() { + return ""; +} + +fs::path nav_put_scenario(fs::path def) { + return ""; +} + + +fs::path nav_get_rsrc(std::initializer_list extensions) { + return ""; +} + +fs::path nav_put_rsrc(std::initializer_list extensions, fs::path def) { + return ""; +} + +void set_clipboard(std::string text) { +} + +std::string get_clipboard() { + return ""; +} + +static void printErr(std::string msg) { +} + +void set_clipboard_img(sf::Image& img) { +} + +std::unique_ptr get_clipboard_img() { + return nullptr; +} + +void beep() { +} + +void launchURL(std::string url) { +} + +// TODO: Implement modal session. +// It seems that Windows doesn't have anything similar to the Mac modal session, so I might have to somehow simulate it myself. +void ModalSession::pumpEvents() { +} + +ModalSession::ModalSession(sf::Window& win, sf::Window& p) : parent(&p) { + +} + +ModalSession::~ModalSession() { +} + +int getMenubarHeight() { + return 1; +}