Tear out most of the legacy code in the PC editor - see below for details
(Scenario Editor is unaffected by this commit.) - Menubar converted to a .xib file - Don't include the Info.plist in "Copy Files" stage - Several more dialogs converted; as before, the source resources have had their resource name changed to the new filename - One more converted STR# has been included There were several functions in the PC Editor code that also existed in the BoE game code. I've moved these into the pc.editors.cpp file, so that there's only one copy of each. - display_alchemy() functions changed signatures - moved keyToChar() function into a common file (winutil) - Several constants and globals moved to pc.editors.cpp Supporting changes to dialog framework: - New formatting option to set the frame style; this because the PC editor uses a different frame style in some contexts - Added global default dialog background setting --> This was necessary to correctly set the default text colour --> Will also be needed for the scenario editor, which uses a different default background Other changes: - Add option to load_scenario to skip loading the strings - Fix for crash in soundtool in the event of initialization before playing the first sound
This commit is contained in:
@@ -98,7 +98,7 @@ static header_posix_ustar generateTarHeader(const std::string& fileName, unsigne
|
||||
return(header);
|
||||
}
|
||||
|
||||
bool load_scenario(fs::path file_to_load){
|
||||
bool load_scenario(fs::path file_to_load, bool skip_strings){
|
||||
short i,n;
|
||||
bool file_ok = false;
|
||||
long len;
|
||||
@@ -155,11 +155,14 @@ bool load_scenario(fs::path file_to_load){
|
||||
port_item_list(item_data);
|
||||
scenario = *temp_scenario;
|
||||
scenario.append(*item_data);
|
||||
// TODO: Consider skipping the fread and assignment when len is 0
|
||||
for (i = 0; i < 270; i++) {
|
||||
len = (long) (scenario.scen_str_len[i]);
|
||||
n = fread(&(scenario.scen_strs(i)), len, 1, file_id);
|
||||
scenario.scen_strs(i)[len] = 0;
|
||||
|
||||
if(!skip_strings) {
|
||||
// TODO: Consider skipping the fread and assignment when len is 0
|
||||
for (i = 0; i < 270; i++) {
|
||||
len = (long) (scenario.scen_str_len[i]);
|
||||
n = fread(&(scenario.scen_strs(i)), len, 1, file_id);
|
||||
scenario.scen_strs(i)[len] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file_id);
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace fs = boost::filesystem; // TODO: Centralize this alias!
|
||||
|
||||
bool load_scenario(fs::path file_to_load);
|
||||
bool load_scenario(fs::path file_to_load, bool skip_strings = false);
|
||||
bool load_town(short which_town, cTown*& the_town);
|
||||
bool load_town(short which_town, cSpeech*& the_talk);
|
||||
bool load_town_str(short which_town, short which_str, char* str);
|
||||
|
@@ -89,6 +89,7 @@ static std::string sound_to_fname_map(snd_num_t snd_num) {
|
||||
|
||||
void init_snd_tool(){
|
||||
short i;
|
||||
ResMgr::setIdMapFn<SoundRsrc>(sound_to_fname_map);
|
||||
|
||||
// TODO: Might need sound 0, not sure
|
||||
for (i = 1; i < NUM_SOUNDS; i++) {
|
||||
|
@@ -14,6 +14,8 @@
|
||||
|
||||
namespace fs = boost::filesystem; // TODO: Centralize this alias
|
||||
|
||||
char keyToChar(sf::Keyboard::Key key, bool isShift);
|
||||
|
||||
bool isFrontWindow(sf::Window& win);
|
||||
void makeFrontWindow(sf::Window& win);
|
||||
|
||||
|
@@ -10,6 +10,66 @@
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
|
||||
// TODO: I'm sure there's a better way to do this (maybe one that's keyboard layout agnostic)
|
||||
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';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool isFrontWindow(sf::Window& win) {
|
||||
sf::WindowHandle handle = win.getSystemHandle();
|
||||
id nsHandle = id(handle);
|
||||
|
Reference in New Issue
Block a user