static void printField (fieldType i) { unsigned char letter = fieldDescs[i].spec->letter; const char *name; const char *language; if (letter == FIELD_LETTER_NO_USE) letter = '-'; if (! fieldDescs[i].spec->name) name = "NONE"; else name = getFieldName (i); if (fieldDescs[i].language == LANG_IGNORE) language = "NONE"; else language = getLanguageName (fieldDescs[i].language); printf((Option.machinable? "%c\t%s\t%s\t%s\t%s\t%s\n": MAKE_FIELD_FMT(c)), letter, name, isFieldEnabled (i)? "on": "off", language, getFieldDesc (i)->spec->renderEscaped? "TRUE": "FALSE", fieldDescs[i].spec->description? fieldDescs[i].spec->description: "NONE"); }
MnemonicSeedDialog::MnemonicSeedDialog(QWidget* _parent) : QDialog(_parent), m_ui(new Ui::MnemonicSeedDialog) { m_ui->setupUi(this); connect(&WalletAdapter::instance(), &WalletAdapter::walletInitCompletedSignal, this, &MnemonicSeedDialog::walletOpened, Qt::QueuedConnection); connect(&WalletAdapter::instance(), &WalletAdapter::walletCloseCompletedSignal, this, &MnemonicSeedDialog::walletClosed, Qt::QueuedConnection); initLanguages(); m_ui->m_languageCombo->setCurrentIndex(m_ui->m_languageCombo->findData(getLanguageName(), Qt::DisplayRole)); }
extern void printKind (const kindDefinition* const kind, bool allKindFields, bool indent, bool tabSeparated) { #define KIND_FMT MAKE_KIND_FMT("", c, d) if (allKindFields) { printf ((tabSeparated ?"%s%c\t%s\t%s\t%s\t%d\t%s\t%s\n" :"%s" KIND_FMT), (indent? (tabSeparated? "\t": " "): ""), kind->letter, kind->name != NULL ? kind->name : "", kind->enabled ? "on" : "off", kind->referenceOnly ? "TRUE" : "FALSE", kind->nRoles, (kind->master || kind->slave ) ? getLanguageName (kind->syncWith): "", kind->description != NULL ? kind->description : ""); } else if (!kind->referenceOnly) { printf ("%s%c %s%s\n", indent ? " " : "", kind->letter, kind->description != NULL ? kind->description : (kind->name != NULL ? kind->name : ""), kind->enabled ? "" : " [off]"); } #undef KIND_FMT }
extern void installLanguageMapDefaults (void) { unsigned int i; for (i = 0 ; i < LanguageCount ; ++i) { verbose (" %s: ", getLanguageName (i)); installLanguageMapDefault (i); } }
bool initProject(Language l) { std::ofstream file(".project"); if(!file) { return false; } file << "Language: "; file << getLanguageName(l) << std::endl; return true; }
const gchar *tm_source_file_get_lang_name(gint lang) { if (NULL == LanguageTable) { initializeParsing(); installLanguageMapDefaults(); if (NULL == TagEntryFunction) TagEntryFunction = tm_source_file_tags; if (NULL == TagEntrySetArglistFunction) TagEntrySetArglistFunction = tm_source_file_set_tag_arglist; } return getLanguageName(lang); }
extern boolean removeLanguageExtensionMap (const char *const extension) { boolean result = FALSE; unsigned int i; for (i = 0 ; i < LanguageCount && ! result ; ++i) { stringList* const exts = LanguageTable [i]->currentExtensions; if (exts != NULL && stringListRemoveExtension (exts, extension)) { verbose (" (removed from %s)", getLanguageName (i)); result = TRUE; } } return result; }
extern void printXcmdKinds (const langType language __unused__, boolean allKindFields __unused__, boolean indent __unused__) { #ifdef HAVE_COPROC if (language <= SetUpper && Sets [language].count > 0) { pathSet* const set = Sets + language; const char* const langName = getLanguageName (language); unsigned int i; for (i = 0 ; i < set->count ; ++i) printXcmdKind (set->paths, i, langName, allKindFields, indent); } #endif }
bool YandexTranslate::parseReply(const QByteArray &reply) { const QVariant data = parseJson(reply); if (!data.isValid()) return false; if (data.toMap().value("detected").type() == QVariant::Map) { const QString detected = data.toMap().value("detected").toMap().value("lang").toString(); m_detectedLanguage = Language(detected, getLanguageName(detected)); } m_translation = data.toMap().value("text").toStringList().join(""); return true; }
extern void printXcmdKinds (const langType language __unused__, boolean allKindFields __unused__, boolean indent __unused__, boolean tabSeparated __unused__) { #ifdef HAVE_COPROC if (language <= SetUpper && Sets [language].count > 0) { const char* const langName = getLanguageName(language); struct printXcmdKindCBData data = { .langName = langName, .allKindFields = allKindFields, .indent = indent, .tabSeparated = tabSeparated, }; foreachXcmdKinds (language, printXcmdKind, &data); } #endif }
extern void printXcmdKinds (const langType language CTAGS_ATTR_UNUSED, bool allKindFields CTAGS_ATTR_UNUSED, bool indent CTAGS_ATTR_UNUSED, bool tabSeparated CTAGS_ATTR_UNUSED) { #ifdef HAVE_COPROC if (language <= SetUpper && Sets [language].count > 0) { const char* const langName = getLanguageName(language); struct printXcmdKindCBData data = { .langName = langName, .allKindFields = allKindFields, .indent = indent, .tabSeparated = tabSeparated, }; foreachXcmdKinds (language, printXcmdKind, &data); } #endif }
LanguagePair YandexTranslate::defaultLanguagePair() const { return LanguagePair(Language("", getLanguageName("")), Language("en", getLanguageName("en"))); }
bool GoogleTranslate::parseReply(const QByteArray &reply) { #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) // JSON coming from Google is invalid due to sequences // like ",,". Replacing all ",," with ",null," allows // us to parse JSON with QJsonDocument. QString json = QString::fromUtf8(reply); if (json.isEmpty()) { m_error = commonString(EmptyResultCommonString).arg(displayName()); return true; } int i = 1; bool skip = json.at(0) == '"'; while (i < json.length()) { const QStringRef mid = json.midRef(i - 1, 2); if (mid.at(1) == '"' && mid.compare(QLatin1String("\\\"")) != 0) { skip = !skip; ++i; } if (!skip && (mid.compare(QLatin1String(",,")) == 0 || mid.compare(QLatin1String("[,")) == 0 || mid.compare(QLatin1String(",]")) == 0)) { json.insert(i, "null"); i += 4; } ++i; } const QVariant data = parseJson(json.toUtf8()); #else const QVariant data = parseJson(reply); #endif if (!data.isValid() || data.type() != QVariant::List) return false; const QVariantList dl = data.toList(); if (dl.isEmpty()) { m_error = commonString(EmptyResultCommonString).arg(displayName()); return true; } const QString detected = dl.value(2).toString(); m_detectedLanguage = Language(detected, getLanguageName(detected)); m_translation.clear(); m_translit = StringPair(); foreach (const QVariant &ti, dl.value(0).toList()) { const QVariantList tr = ti.toList(); if (!tr.value(0).isNull()) m_translation.append(tr.value(0).toString()); if (!tr.value(2).isNull()) m_translit.second.append(tr.value(2).toString()); if (!tr.value(3).isNull()) m_translit.first.append(tr.value(3).toString()); } m_dict->clear(); if (dl.value(1).type() == QVariant::List) { foreach (const QVariant &di, dl.value(1).toList()) { const QVariantList dil = di.toList(); // Translations const QStringList trans = dil.value(1).toStringList(); // Part of speech DictionaryPos pos(dil.value(0).toString(), trans); // Reverse translations foreach (const QVariant &ei, dil.value(2).toList()) { const QVariantList eil = ei.toList(); // Word from translations for which reverse translations are provided QString word = eil.value(0).toString(); // Reverse translations for the aforementioned word const QStringList rtrans = eil.value(1).toStringList(); // Article for the aforementioned word (if provided) if (!eil.value(4).toString().isEmpty()) word.prepend(eil.value(4).toString() + " "); pos.reverseTranslations()->append(word, QStringList(), rtrans); } m_dict->append(pos); } }
extern const char *getInputLanguageName (void) { return getLanguageName (getInputLanguage()); }
static boolean loadPathKinds (xcmdPath *const path, const langType language) { enum pcoprocError r; FILE* pp = NULL; char * argv[3]; int status; vString * opt; char file_kind = getLanguageFileKind (language)->letter; opt = vStringNewInit(XCMD_LIST_KIND_OPTION); vStringCatS (opt, "="); vStringCatS (opt, getLanguageName(language)); argv[2] = NULL; argv[1] = vStringValue (opt); argv[0] = vStringValue (path->path); errno = 0; if (getuid() == 0 || geteuid() == 0) { verbose ("all xcmd feature is disabled when running ctags in root privilege\n"); vStringDelete (opt); return FALSE; } if (! isSafeExecutable (argv [0])) { vStringDelete (opt); return FALSE; } verbose ("loading path kinds of %s from [%s %s]\n", getLanguageName(language), argv[0], argv[1]); r = pcoprocOpen (vStringValue (path->path), argv, &pp, NULL); switch (r) { case PCOPROC_ERROR_WPIPE: error (WARNING | PERROR, "failed to make pipe to write to command: [%s %s]", argv[0], argv[1]); break; case PCOPROC_ERROR_RPIPE: error (WARNING | PERROR, "failed to make pipe to read from command: [%s %s]", argv[0], argv[1]); break; case PCOPROC_ERROR_FORK: error (WARNING | PERROR, "failed to do fork: [%s %s]", argv[0], argv[1]); break; case PCOPROC_SUCCESSFUL: break; } if (pp) { vString* vline = vStringNew(); while (readLineRawWithNoSeek (vline, pp)) { char* line; char kind_letter; vStringStripNewline (vline); line = vStringValue (vline); if (!loadPathKind (path, line, argv)) break; kind_letter = path->kinds [path->n_kinds - 1].letter; if (kind_letter == file_kind) error (FATAL, "Kind letter \'%c\' returned from xcmd %s of %s language is reserved in ctags main", kind_letter, vStringValue (path->path), getLanguageName (language)); } vStringDelete (vline); status = pcoprocClose (pp); /* TODO: Decode status */ verbose(" status: %d\n", status); if (status != 0) { if (status > 0 && WIFEXITED (status) && (WEXITSTATUS (status) == path->not_available_status)) verbose ("xcmd: the %s backend is not available\n", argv[0]); else error (WARNING, "xcmd exits abnormally status(%d): [%s %s]", status, argv[0], argv[1]); vStringDelete (opt); return FALSE; } } else { error (WARNING | PERROR, "cannot make pipe to xcmd: [%s %s]", argv[0], argv[1]); } vStringDelete (opt); return path->kinds == NULL? FALSE: TRUE; }
int realmain(int argc, char *argv[]) { // The libcrypto startup stuff... May or may not actually be needed for anything at all. ERR_load_crypto_strings(); // This is needed for descriptive error messages. OpenSSL_add_all_algorithms(); // Don't actually use the EVP functions, so probably not needed. OPENSSL_config(nullptr); // What does this actually do? #ifdef WZ_OS_WIN RAND_screen(); // Uses a screenshot as a random seed, on systems lacking /dev/random. #endif wzMain(argc, argv); int utfargc = argc; const char** utfargv = (const char**)argv; #ifdef WZ_OS_MAC cocoaInit(); #endif debug_init(); debug_register_callback( debug_callback_stderr, NULL, NULL, NULL ); #if defined(WZ_OS_WIN) && defined(DEBUG_INSANE) debug_register_callback( debug_callback_win32debug, NULL, NULL, NULL ); #endif // WZ_OS_WIN && DEBUG_INSANE // ***** // NOTE: Try *NOT* to use debug() output routines without some other method of informing the user. All this output is sent to /dev/nul at this point on some platforms! // ***** if (!getUTF8CmdLine(&utfargc, &utfargv)) { return EXIT_FAILURE; } QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); // make Qt treat all C strings in Warzone as UTF-8 setupExceptionHandler(utfargc, utfargv, version_getFormattedVersionString()); /*** Initialize PhysicsFS ***/ initialize_PhysicsFS(utfargv[0]); /*** Initialize translations ***/ initI18n(); // find early boot info if (!ParseCommandLineEarly(utfargc, utfargv)) { return EXIT_FAILURE; } /* Initialize the write/config directory for PhysicsFS. * This needs to be done __after__ the early commandline parsing, * because the user might tell us to use an alternative configuration * directory. */ initialize_ConfigDir(); /*** Initialize directory structure ***/ make_dir(ScreenDumpPath, "screenshots", NULL); make_dir(SaveGamePath, "savegames", NULL); PHYSFS_mkdir("savegames/campaign"); PHYSFS_mkdir("savegames/skirmish"); make_dir(MultiCustomMapsPath, "maps", NULL); // MUST have this to prevent crashes when getting map PHYSFS_mkdir("music"); PHYSFS_mkdir("logs"); // a place to hold our netplay, mingw crash reports & WZ logs PHYSFS_mkdir("userdata"); // a place to store per-mod data user generated data memset(rulesettag, 0, sizeof(rulesettag)); // tag to add to userdata to find user generated stuff make_dir(MultiPlayersPath, "multiplay", NULL); make_dir(MultiPlayersPath, "multiplay", "players"); if (!customDebugfile) { // there was no custom debug file specified (--debug-file=blah) // so we use our write directory to store our logs. time_t aclock; struct tm *newtime; char buf[PATH_MAX]; time( &aclock ); // Get time in seconds newtime = localtime( &aclock ); // Convert time to struct // Note: We are using fopen(), and not physfs routines to open the file // log name is logs/(or \)WZlog-MMDD_HHMMSS.txt snprintf(buf, sizeof(buf), "%slogs%sWZlog-%02d%02d_%02d%02d%02d.txt", PHYSFS_getWriteDir(), PHYSFS_getDirSeparator(), newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec ); debug_register_callback( debug_callback_file, debug_callback_file_init, debug_callback_file_exit, buf ); // FIXME: Change this to LOG_WZ on next release debug(LOG_INFO, "Using %s debug file", buf); } // NOTE: it is now safe to use debug() calls to make sure output gets captured. check_Physfs(); debug(LOG_WZ, "Warzone 2100 - %s", version_getFormattedVersionString()); debug(LOG_WZ, "Using language: %s", getLanguage()); debug(LOG_WZ, "Backend: %s", BACKEND); debug(LOG_MEMORY, "sizeof: SIMPLE_OBJECT=%ld, BASE_OBJECT=%ld, DROID=%ld, STRUCTURE=%ld, FEATURE=%ld, PROJECTILE=%ld", (long)sizeof(SIMPLE_OBJECT), (long)sizeof(BASE_OBJECT), (long)sizeof(DROID), (long)sizeof(STRUCTURE), (long)sizeof(FEATURE), (long)sizeof(PROJECTILE)); /* Put in the writedir root */ sstrcpy(KeyMapPath, "keymap.map"); // initialise all the command line states war_SetDefaultStates(); debug(LOG_MAIN, "initializing"); PhysicsEngineHandler engine; // register abstract physfs filesystem loadConfig(); // parse the command line if (!ParseCommandLine(utfargc, utfargv)) { return EXIT_FAILURE; } // Save new (commandline) settings saveConfig(); // Find out where to find the data scanDataDirs(); // Now we check the mods to see if they exist or not (specified on the command line) // They are all capped at 100 mods max(see clparse.c) // FIX ME: I know this is a bit hackish, but better than nothing for now? { char *modname; char modtocheck[256]; int i = 0; int result = 0; // check global mods for(i=0; i < 100; i++) { modname = global_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/global/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The (global) mod (%s) you have specified doesn't exist!", modname); } else { info("(global) mod (%s) is enabled", modname); } } // check campaign mods for(i=0; i < 100; i++) { modname = campaign_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/campaign/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The mod_ca (%s) you have specified doesn't exist!", modname); } else { info("mod_ca (%s) is enabled", modname); } } // check multiplay mods for(i=0; i < 100; i++) { modname = multiplay_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/multiplay/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The mod_mp (%s) you have specified doesn't exist!", modname); } else { info("mod_mp (%s) is enabled", modname); } } } if (!wzMain2(war_getFSAA(), war_getFullscreen(), war_GetVsync())) { return EXIT_FAILURE; } int w = pie_GetVideoBufferWidth(); int h = pie_GetVideoBufferHeight(); char buf[256]; ssprintf(buf, "Video Mode %d x %d (%s)", w, h, war_getFullscreen() ? "fullscreen" : "window"); addDumpInfo(buf); debug(LOG_MAIN, "Final initialization"); if (!frameInitialise()) { return EXIT_FAILURE; } if (!screenInitialise()) { return EXIT_FAILURE; } if (!pie_LoadShaders()) { return EXIT_FAILURE; } war_SetWidth(pie_GetVideoBufferWidth()); war_SetHeight(pie_GetVideoBufferHeight()); pie_SetFogStatus(false); pie_ScreenFlip(CLEAR_BLACK); pal_Init(); pie_LoadBackDrop(SCREEN_RANDOMBDROP); pie_SetFogStatus(false); pie_ScreenFlip(CLEAR_BLACK); if (!systemInitialise()) { return EXIT_FAILURE; } //set all the pause states to false setAllPauseStates(false); // Copy this info to be used by the crash handler for the dump file ssprintf(buf,"Using Backend: %s", BACKEND); addDumpInfo(buf); ssprintf(buf,"Using language: %s", getLanguageName()); addDumpInfo(buf); // Do the game mode specific initialisation. switch(GetGameMode()) { case GS_TITLE_SCREEN: startTitleLoop(); break; case GS_SAVEGAMELOAD: initSaveGameLoad(); break; case GS_NORMAL: startGameLoop(); break; default: debug(LOG_ERROR, "Weirdy game status, I'm afraid!!"); break; } #if defined(WZ_CC_MSVC) && defined(DEBUG) debug_MEMSTATS(); #endif debug(LOG_MAIN, "Entering main loop"); wzMain3(); saveConfig(); systemShutdown(); #ifdef WZ_OS_WIN // clean up the memory allocated for the command line conversion for (int i=0; i<argc; i++) { const char*** const utfargvF = &utfargv; free((void *)(*utfargvF)[i]); } free(utfargv); #endif wzShutdown(); debug(LOG_MAIN, "Completed shutting down Warzone 2100"); return EXIT_SUCCESS; }
static boolean loadPathKinds (xcmdPath *const path, const langType language) { enum pcoproc_error r; FILE* pp = NULL; char * argv[3]; int status; vString * opt; opt = vStringNewInit(XCMD_LIST_KIND_OPTION); vStringCatS (opt, "="); vStringCatS (opt, getLanguageName(language)); argv[2] = NULL; argv[1] = vStringValue (opt); argv[0] = vStringValue (path->path); errno = 0; verbose ("loading path kinds of %s from [%s %s]\n", getLanguageName(language), argv[0], argv[1]); r = pcoproc_open (vStringValue (path->path), argv, &pp, NULL); switch (r) { case PCOPROC_ERROR_WPIPE: error (WARNING | PERROR, "failed to make pipe to write to command: [%s %s]", argv[0], argv[1]); break; case PCOPROC_ERROR_RPIPE: error (WARNING | PERROR, "failed to make pipe to read from command: [%s %s]", argv[0], argv[1]); break; case PCOPROC_ERROR_FORK: error (WARNING | PERROR, "failed to do fork: [%s %s]", argv[0], argv[1]); break; case PCOPROC_SUCCESSFUL: break; } if (pp) { vString* vline = vStringNew(); while (readLineWithNoSeek (vline, pp)) { char* line; vStringStripNewline (vline); line = vStringValue (vline); if (!loadPathKind (path, line, argv)) break; } vStringDelete (vline); status = pcoproc_close (pp); /* TODO: Decode status */ verbose(" status: %d\n", status); if (status != 0) { if (status > 0 && WIFEXITED (status) && (WEXITSTATUS (status) == XCMD_NOT_AVAILABLE_STATUS)) notice ("xcmd recognizes %s is not available", argv[0]); else error (WARNING, "xcmd exits abnormally status(%d): [%s %s]", status, argv[0], argv[1]); vStringDelete (opt); return FALSE; } } else { error (WARNING | PERROR, "cannot make pipe to xcmd: [%s %s]", argv[0], argv[1]); } vStringDelete (opt); return path->kinds == NULL? FALSE: TRUE; }
bool runGameOptionsMenu(void) { UDWORD id; id = widgRunScreen(psWScreen); // Run the current set of widgets switch(id) { case FRONTEND_LANGUAGE_R: setNextLanguage(); widgSetString(psWScreen, FRONTEND_LANGUAGE_R, getLanguageName()); /* Hack to reset current menu text, which looks fancy. */ widgSetString(psWScreen, FRONTEND_LANGUAGE, _("Language")); widgSetString(psWScreen, FRONTEND_COLOUR, _("Unit Colour")); widgSetString(psWScreen, FRONTEND_DIFFICULTY, _("Difficulty")); widgSetString(psWScreen, FRONTEND_SCROLLSPEED,_("Scroll Speed")); widgSetString(psWScreen, FRONTEND_SIDETEXT, _("GAME OPTIONS")); // FIXME: Changing the below return button tooltip does not work. //widgSetString(psWScreen, FRONTEND_BOTFORM, P_("menu", "Return")); switch( getDifficultyLevel() ) { case DL_EASY: widgSetString(psWScreen,FRONTEND_DIFFICULTY_R, _("Easy")); break; case DL_NORMAL: widgSetString(psWScreen,FRONTEND_DIFFICULTY_R, _("Normal")); break; case DL_HARD: widgSetString(psWScreen,FRONTEND_DIFFICULTY_R, _("Hard") ); break; case DL_TOUGH: case DL_KILLER: debug(LOG_ERROR, "runGameOptionsMenu: Unused difficulty level selected!"); break; } break; case FRONTEND_RADAR_R: rotateRadar = !rotateRadar; widgSetString(psWScreen, FRONTEND_RADAR_R, rotateRadar ? _("Rotating") : _("Fixed")); break; case FRONTEND_SCROLLSPEED: break; case FRONTEND_DIFFICULTY: case FRONTEND_DIFFICULTY_R: switch( getDifficultyLevel() ) { case DL_EASY: setDifficultyLevel(DL_NORMAL); widgSetString(psWScreen,FRONTEND_DIFFICULTY_R, _("Normal")); break; case DL_NORMAL: setDifficultyLevel(DL_HARD); widgSetString(psWScreen,FRONTEND_DIFFICULTY_R, _("Hard") ); break; case DL_HARD: setDifficultyLevel(DL_EASY); widgSetString(psWScreen,FRONTEND_DIFFICULTY_R, _("Easy")); break; default: // DL_TOUGH and DL_KILLER break; } break; case FRONTEND_SCROLLSPEED_SL: scroll_speed_accel = widgGetSliderPos(psWScreen,FRONTEND_SCROLLSPEED_SL) * 100; //0-1600 if(scroll_speed_accel ==0) // make sure you CAN scroll. { scroll_speed_accel = 100; } break; case FRONTEND_QUIT: changeTitleMode(OPTIONS); break; case FE_P0: widgSetButtonState(psWScreen, FE_P0, WBUT_LOCK); widgSetButtonState(psWScreen, FE_P4, 0); widgSetButtonState(psWScreen, FE_P5, 0); widgSetButtonState(psWScreen, FE_P6, 0); widgSetButtonState(psWScreen, FE_P7, 0); war_SetSPcolor(0); break; case FE_P4: widgSetButtonState(psWScreen, FE_P0, 0); widgSetButtonState(psWScreen, FE_P4, WBUT_LOCK); widgSetButtonState(psWScreen, FE_P5, 0); widgSetButtonState(psWScreen, FE_P6, 0); widgSetButtonState(psWScreen, FE_P7, 0); war_SetSPcolor(4); break; case FE_P5: widgSetButtonState(psWScreen, FE_P0, 0); widgSetButtonState(psWScreen, FE_P4, 0); widgSetButtonState(psWScreen, FE_P5, WBUT_LOCK); widgSetButtonState(psWScreen, FE_P6, 0); widgSetButtonState(psWScreen, FE_P7, 0); war_SetSPcolor(5); break; case FE_P6: widgSetButtonState(psWScreen, FE_P0, 0); widgSetButtonState(psWScreen, FE_P4, 0); widgSetButtonState(psWScreen, FE_P5, 0); widgSetButtonState(psWScreen, FE_P6, WBUT_LOCK); widgSetButtonState(psWScreen, FE_P7, 0); war_SetSPcolor(6); break; case FE_P7: widgSetButtonState(psWScreen, FE_P0, 0); widgSetButtonState(psWScreen, FE_P4, 0); widgSetButtonState(psWScreen, FE_P5, 0); widgSetButtonState(psWScreen, FE_P6, 0); widgSetButtonState(psWScreen, FE_P7, WBUT_LOCK); war_SetSPcolor(7); break; default: break; } // If close button pressed then return from this menu. if(CancelPressed()) { changeTitleMode(OPTIONS); } widgDisplayScreen(psWScreen); // show the widgets currently running return true; }
// //////////////////////////////////////////////////////////////////////////// // Game Options Menu static bool startGameOptionsMenu(void) { UDWORD w, h; int playercolor; addBackdrop(); addTopForm(); addBottomForm(); // Difficulty addTextButton(FRONTEND_DIFFICULTY, FRONTEND_POS2X-25, FRONTEND_POS2Y, _("Difficulty"), 0); switch (getDifficultyLevel()) { case DL_EASY: addTextButton(FRONTEND_DIFFICULTY_R, FRONTEND_POS2M-25, FRONTEND_POS2Y, _("Easy"), 0); break; case DL_NORMAL: addTextButton(FRONTEND_DIFFICULTY_R, FRONTEND_POS2M-25,FRONTEND_POS2Y, _("Normal"), 0); break; case DL_HARD: default: addTextButton(FRONTEND_DIFFICULTY_R, FRONTEND_POS2M-25, FRONTEND_POS2Y, _("Hard"), 0); break; } // Scroll speed addTextButton(FRONTEND_SCROLLSPEED, FRONTEND_POS3X-25, FRONTEND_POS3Y, _("Scroll Speed"), 0); addFESlider(FRONTEND_SCROLLSPEED_SL, FRONTEND_BOTFORM, FRONTEND_POS3M, FRONTEND_POS3Y+5, 16, scroll_speed_accel / 100); // Colour stuff w = iV_GetImageWidth(FrontImages, IMAGE_PLAYERN); h = iV_GetImageHeight(FrontImages, IMAGE_PLAYERN); addMultiBut(psWScreen, FRONTEND_BOTFORM, FE_P0, FRONTEND_POS4M+(0*(w+6)), FRONTEND_POS4Y, w, h, NULL, IMAGE_PLAYERN, IMAGE_PLAYERX, true, 0); addMultiBut(psWScreen, FRONTEND_BOTFORM, FE_P4, FRONTEND_POS4M+(1*(w+6)), FRONTEND_POS4Y, w, h, NULL, IMAGE_PLAYERN, IMAGE_PLAYERX, true, 4); addMultiBut(psWScreen, FRONTEND_BOTFORM, FE_P5, FRONTEND_POS4M+(2*(w+6)), FRONTEND_POS4Y, w, h, NULL, IMAGE_PLAYERN, IMAGE_PLAYERX, true, 5); addMultiBut(psWScreen, FRONTEND_BOTFORM, FE_P6, FRONTEND_POS4M+(3*(w+6)), FRONTEND_POS4Y, w, h, NULL, IMAGE_PLAYERN, IMAGE_PLAYERX, true, 6); addMultiBut(psWScreen, FRONTEND_BOTFORM, FE_P7, FRONTEND_POS4M+(4*(w+6)), FRONTEND_POS4Y, w, h, NULL, IMAGE_PLAYERN, IMAGE_PLAYERX, true, 7); // language addTextButton(FRONTEND_LANGUAGE, FRONTEND_POS2X - 25, FRONTEND_POS5Y, _("Language"), 0); addTextButton(FRONTEND_LANGUAGE_R, FRONTEND_POS2M - 25, FRONTEND_POS5Y, getLanguageName(), 0); // FIXME: if playercolor = 1-3, then we Assert in widgSetButtonState() since we don't define FE_P1 - FE_P3 // I assume the reason is that in SP games, those are reserved for the AI? Valid values are 0, 4-7. // This is a workaround, until we find what is setting that to 1-3. See configuration.c:701 playercolor = war_GetSPcolor(); if (playercolor >= 1 && playercolor <= 3) { playercolor = 0; } widgSetButtonState(psWScreen, FE_P0 + playercolor, WBUT_LOCK); addTextButton(FRONTEND_COLOUR, FRONTEND_POS4X-25, FRONTEND_POS4Y, _("Unit Colour"), 0); // Radar addTextButton(FRONTEND_RADAR, FRONTEND_POS6X - 25, FRONTEND_POS6Y, _("Radar"), 0); addTextButton(FRONTEND_RADAR_R, FRONTEND_POS6M - 25, FRONTEND_POS6Y, rotateRadar ? _("Rotating") : _("Fixed"), 0); // Quit addMultiBut(psWScreen, FRONTEND_BOTFORM, FRONTEND_QUIT, 10, 10, 30, 29, P_("menu", "Return"), IMAGE_RETURN, IMAGE_RETURN_HI, IMAGE_RETURN_HI); // Add some text down the side of the form addSideText(FRONTEND_SIDETEXT, FRONTEND_SIDEX, FRONTEND_SIDEY, _("GAME OPTIONS")); return true; }
void MnemonicSeedDialog::walletOpened() { CryptoNote::AccountKeys keys; WalletAdapter::instance().getAccountKeys(keys); QString mnemonicSeed = WalletAdapter::instance().getMnemonicSeed(getLanguageName()); m_ui->m_mnemonicSeedEdit->setText(mnemonicSeed); }
void Keywords::printEntry (const hashEntry *const entry) { printf (" %-15s %-7s\n", entry->string, getLanguageName (entry->language)); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); int utfargc = argc; const char** utfargv = (const char**)argv; #ifdef WZ_OS_MAC cocoaInit(); #endif debug_init(); debug_register_callback( debug_callback_stderr, NULL, NULL, NULL ); #if defined(WZ_OS_WIN) && defined(DEBUG_INSANE) debug_register_callback( debug_callback_win32debug, NULL, NULL, NULL ); #endif // WZ_OS_WIN && DEBUG_INSANE // ***** // NOTE: Try *NOT* to use debug() output routines without some other method of informing the user. All this output is sent to /dev/nul at this point on some platforms! // ***** if (!getUTF8CmdLine(&utfargc, &utfargv)) { return EXIT_FAILURE; } QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); // make Qt treat all C strings in Warzone as UTF-8 setupExceptionHandler(utfargc, utfargv, version_getFormattedVersionString()); /*** Initialize PhysicsFS ***/ initialize_PhysicsFS(utfargv[0]); /*** Initialize translations ***/ initI18n(); // find early boot info if (!ParseCommandLineEarly(utfargc, utfargv)) { return EXIT_FAILURE; } /* Initialize the write/config directory for PhysicsFS. * This needs to be done __after__ the early commandline parsing, * because the user might tell us to use an alternative configuration * directory. */ initialize_ConfigDir(); /*** Initialize directory structure ***/ make_dir(ScreenDumpPath, "screenshots", NULL); make_dir(SaveGamePath, "savegames", NULL); make_dir(MultiCustomMapsPath, "maps", NULL); // MUST have this to prevent crashes when getting map PHYSFS_mkdir("music"); PHYSFS_mkdir("logs"); // a place to hold our netplay, mingw crash reports & WZ logs make_dir(MultiPlayersPath, "multiplay", NULL); make_dir(MultiPlayersPath, "multiplay", "players"); if (!customDebugfile) { // there was no custom debug file specified (--debug-file=blah) // so we use our write directory to store our logs. time_t aclock; struct tm *newtime; char buf[PATH_MAX]; time( &aclock ); // Get time in seconds newtime = localtime( &aclock ); // Convert time to struct // Note: We are using fopen(), and not physfs routines to open the file // log name is logs/(or \)WZlog-MMDD_HHMMSS.txt snprintf(buf, sizeof(buf), "%slogs%sWZlog-%02d%02d_%02d%02d%02d.txt", PHYSFS_getWriteDir(), PHYSFS_getDirSeparator(), newtime->tm_mon, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec ); debug_register_callback( debug_callback_file, debug_callback_file_init, debug_callback_file_exit, buf ); } // NOTE: it is now safe to use debug() calls to make sure output gets captured. check_Physfs(); debug(LOG_WZ, "Warzone 2100 - %s", version_getFormattedVersionString()); debug(LOG_WZ, "Using language: %s", getLanguage()); debug(LOG_MEMORY, "sizeof: SIMPLE_OBJECT=%ld, BASE_OBJECT=%ld, DROID=%ld, STRUCTURE=%ld, FEATURE=%ld, PROJECTILE=%ld", (long)sizeof(SIMPLE_OBJECT), (long)sizeof(BASE_OBJECT), (long)sizeof(DROID), (long)sizeof(STRUCTURE), (long)sizeof(FEATURE), (long)sizeof(PROJECTILE)); /* Put in the writedir root */ sstrcpy(KeyMapPath, "keymap.map"); // initialise all the command line states war_SetDefaultStates(); debug(LOG_MAIN, "initializing"); PhysicsEngineHandler engine; // register abstract physfs filesystem loadConfig(); // parse the command line if (!ParseCommandLine(utfargc, utfargv)) { return EXIT_FAILURE; } // Save new (commandline) settings saveConfig(); // Find out where to find the data scanDataDirs(); // This needs to be done after "scanDataDirs" // for the root cert from cacert. NETinit(true); // Must be run before OpenGL driver is properly initialized due to // strange conflicts - Per if (selfTest) { memset(enabled_debug, 0, sizeof(*enabled_debug) * LOG_LAST); fprintf(stdout, "Carrying out self-test:\n"); playListTest(); audioTest(); soundTest(); } // Now we check the mods to see if they exist or not (specified on the command line) // They are all capped at 100 mods max(see clparse.c) // FIX ME: I know this is a bit hackish, but better than nothing for now? { char *modname; char modtocheck[256]; int i = 0; int result = 0; // check global mods for(i=0; i < 100; i++) { modname = global_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/global/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The (global) mod (%s) you have specified doesn't exist!", modname); } else { info("(global) mod (%s) is enabled", modname); } } // check campaign mods for(i=0; i < 100; i++) { modname = campaign_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/campaign/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The mod_ca (%s) you have specified doesn't exist!", modname); } else { info("mod_ca (%s) is enabled", modname); } } // check multiplay mods for(i=0; i < 100; i++) { modname = multiplay_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/multiplay/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The mod_mp (%s) you have specified doesn't exist!", modname); } else { info("mod_mp (%s) is enabled", modname); } } } debug(LOG_MAIN, "Qt initialization"); QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); // Workaround for incorrect text rendering on nany platforms. // Setting up OpenGL QGLFormat format; format.setDoubleBuffer(true); format.setAlpha(true); int w = pie_GetVideoBufferWidth(); int h = pie_GetVideoBufferHeight(); if (war_getFSAA()) { format.setSampleBuffers(true); format.setSamples(war_getFSAA()); } WzMainWindow mainwindow(QSize(w, h), format); mainwindow.setMinimumResolution(QSize(800, 600)); if (!mainwindow.context()->isValid()) { QMessageBox::critical(NULL, "Oops!", "Warzone2100 failed to create an OpenGL context. This probably means that your graphics drivers are out of date. Try updating them!"); return EXIT_FAILURE; } screenWidth = w; screenHeight = h; if (war_getFullscreen()) { mainwindow.resize(w,h); mainwindow.showFullScreen(); if(w>mainwindow.width()) { w = mainwindow.width(); } if(h>mainwindow.height()) { h = mainwindow.height(); } pie_SetVideoBufferWidth(w); pie_SetVideoBufferHeight(h); } else { mainwindow.show(); mainwindow.setMinimumSize(w, h); mainwindow.setMaximumSize(w, h); } mainwindow.setSwapInterval(war_GetVsync()); war_SetVsync(mainwindow.swapInterval() > 0); mainwindow.setReadyToPaint(); char buf[256]; ssprintf(buf, "Video Mode %d x %d (%s)", w, h, war_getFullscreen() ? "fullscreen" : "window"); addDumpInfo(buf); debug(LOG_MAIN, "Final initialization"); if (!frameInitialise()) { return EXIT_FAILURE; } war_SetWidth(pie_GetVideoBufferWidth()); war_SetHeight(pie_GetVideoBufferHeight()); pie_SetFogStatus(false); pie_ScreenFlip(CLEAR_BLACK); pal_Init(); pie_LoadBackDrop(SCREEN_RANDOMBDROP); pie_SetFogStatus(false); pie_ScreenFlip(CLEAR_BLACK); if (!systemInitialise()) { return EXIT_FAILURE; } //set all the pause states to false setAllPauseStates(false); /* Runtime unit testing */ if (selfTest) { parseTest(); levTest(); mapTest(); fprintf(stdout, "All tests PASSED!\n"); exit(0); } // Copy this info to be used by the crash handler for the dump file ssprintf(buf,"Using language: %s", getLanguageName()); addDumpInfo(buf); // Do the game mode specific initialisation. switch(GetGameMode()) { case GS_TITLE_SCREEN: startTitleLoop(); break; case GS_SAVEGAMELOAD: initSaveGameLoad(); break; case GS_NORMAL: startGameLoop(); break; default: debug(LOG_ERROR, "Weirdy game status, I'm afraid!!"); break; } #if defined(WZ_CC_MSVC) && defined(DEBUG) debug_MEMSTATS(); #endif debug(LOG_MAIN, "Entering main loop"); app.exec(); saveConfig(); systemShutdown(); debug(LOG_MAIN, "Completed shutting down Warzone 2100"); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { int utfargc = argc; const char** utfargv = (const char**)argv; #ifdef WZ_OS_MAC cocoaInit(); #endif debug_init(); debug_register_callback( debug_callback_stderr, NULL, NULL, NULL ); #if defined(WZ_OS_WIN) && defined(DEBUG_INSANE) debug_register_callback( debug_callback_win32debug, NULL, NULL, NULL ); #endif // WZ_OS_WIN && DEBUG_INSANE if (!getUTF8CmdLine(&utfargc, &utfargv)) { return -1; } setupExceptionHandler(utfargc, utfargv); /*** Initialize PhysicsFS ***/ initialize_PhysicsFS(utfargv[0]); /*** Initialize translations ***/ initI18n(); // find early boot info if ( !ParseCommandLineEarly(utfargc, utfargv) ) { return -1; } debug(LOG_WZ, "Using language: %s", getLanguage()); debug(LOG_MEMORY, "sizeof: SIMPLE_OBJECT=%ld, BASE_OBJECT=%ld, DROID=%ld, STRUCTURE=%ld, FEATURE=%ld, PROJECTILE=%ld", (long)sizeof(SIMPLE_OBJECT), (long)sizeof(BASE_OBJECT), (long)sizeof(DROID), (long)sizeof(STRUCTURE), (long)sizeof(FEATURE), (long)sizeof(PROJECTILE)); /* Initialize the write/config directory for PhysicsFS. * This needs to be done __after__ the early commandline parsing, * because the user might tell us to use an alternative configuration * directory. */ initialize_ConfigDir(); /*** Initialize directory structure ***/ make_dir(ScreenDumpPath, "screenshots", NULL); make_dir(SaveGamePath, "savegame", NULL); make_dir(MultiCustomMapsPath, "maps", NULL); // MUST have this to prevent crashes when getting map PHYSFS_mkdir("music"); PHYSFS_mkdir("logs"); // a place to hold our netplay, mingw crash reports & WZ logs make_dir(MultiPlayersPath, "multiplay", NULL); make_dir(MultiPlayersPath, "multiplay", "players"); if (!customDebugfile) { // there was no custom debug file specified (--debug-file=blah) // so we use our write directory to store our logs. time_t aclock; struct tm *newtime; char buf[PATH_MAX]; time( &aclock ); // Get time in seconds newtime = localtime( &aclock ); // Convert time to struct // Note: We are using fopen(), and not physfs routines to open the file // log name is logs/(or \)WZlog-MMDD_HHMMSS.txt snprintf(buf, sizeof(buf), "%slogs%sWZlog-%02d%02d_%02d%02d%02d.txt", PHYSFS_getWriteDir(), PHYSFS_getDirSeparator(), newtime->tm_mon, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec ); debug_register_callback( debug_callback_file, debug_callback_file_init, debug_callback_file_exit, buf ); } debug(LOG_WZ, "Warzone 2100 - %s", version_getFormattedVersionString()); /* Put these files in the writedir root */ setRegistryFilePath("config"); sstrcpy(KeyMapPath, "keymap.map"); // initialise all the command line states war_SetDefaultStates(); debug(LOG_MAIN, "initializing"); loadConfig(); NETinit(true); // parse the command line if (!ParseCommandLine(utfargc, utfargv)) { return -1; } // Save new (commandline) settings saveConfig(); // Find out where to find the data scanDataDirs(); // Must be run before OpenGL driver is properly initialized due to // strange conflicts - Per if (selfTest) { memset(enabled_debug, 0, sizeof(*enabled_debug) * LOG_LAST); fprintf(stdout, "Carrying out self-test:\n"); playListTest(); audioTest(); soundTest(); } // Now we check the mods to see if they exsist or not (specified on the command line) // They are all capped at 100 mods max(see clparse.c) // FIX ME: I know this is a bit hackish, but better than nothing for now? { char *modname; char modtocheck[256]; int i = 0; int result = 0; // check global mods for(i=0; i < 100; i++) { modname = global_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/global/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The (global) mod (%s) you have specified doesn't exist!", modname); } else { info("(global) mod (%s) is enabled", modname); } } // check campaign mods for(i=0; i < 100; i++) { modname = campaign_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/campaign/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The mod_ca (%s) you have specified doesn't exist!", modname); } else { info("mod_ca (%s) is enabled", modname); } } // check multiplay mods for(i=0; i < 100; i++) { modname = multiplay_mods[i]; if (modname == NULL) { break; } ssprintf(modtocheck, "mods/multiplay/%s", modname); result = PHYSFS_exists(modtocheck); result |= PHYSFS_isDirectory(modtocheck); if (!result) { debug(LOG_ERROR, "The mod_mp (%s) you have specified doesn't exist!", modname); } else { info("mod_mp (%s) is enabled", modname); } } } if (!frameInitialise( "Warzone 2100", pie_GetVideoBufferWidth(), pie_GetVideoBufferHeight(), pie_GetVideoBufferDepth(), war_getFSAA(), war_getFullscreen(), war_GetVsync())) { return -1; } war_SetWidth(pie_GetVideoBufferWidth()); war_SetHeight(pie_GetVideoBufferHeight()); pie_SetFogStatus(false); pie_ScreenFlip(CLEAR_BLACK); pal_Init(); pie_LoadBackDrop(SCREEN_RANDOMBDROP); pie_SetFogStatus(false); pie_ScreenFlip(CLEAR_BLACK); if (!systemInitialise()) { return -1; } //set all the pause states to false setAllPauseStates(false); /* Runtime unit testing */ if (selfTest) { tagTest(); parseTest(); levTest(); mapTest(); fprintf(stdout, "All tests PASSED!\n"); exit(0); } { // Copy this info to be used by the crash handler for the dump file char buf[256]; ssprintf(buf,"Using language: %s", getLanguageName()); addDumpInfo(buf); } // Do the game mode specific initialisation. switch(GetGameMode()) { case GS_TITLE_SCREEN: startTitleLoop(); break; case GS_SAVEGAMELOAD: initSaveGameLoad(); break; case GS_NORMAL: startGameLoop(); break; default: debug(LOG_ERROR, "Weirdy game status, I'm afraid!!"); break; } debug(LOG_MAIN, "Entering main loop"); // Enter the mainloop mainLoop(); debug(LOG_MAIN, "Shutting down Warzone 2100"); #if defined(WZ_CC_MSVC) && defined(DEBUG) debug_MEMSTATS(); #endif atexit(systemShutdown); return EXIT_SUCCESS; }