void FuncDefs::ParseDefs() { for (int i = 0; i < m_NumOfDefs; i++) { LPCTSTR def = m_StrDefs[i]; KeyBind *p = m_Defs[i]; LPCTSTR last = def + _tcslen(def) - 1; if (*def == _T('"') && *last == _T('"')) { ++def; // skip '"' while (def < last) *p++ = ParseKey(def); } else if (*def == _T('[') && *last == _T(']')) { while (++def < last) { // skip '[', ']', and ' ' if (*def == _T('?')) { // [?f ?o ?o] *p++ = ParseKey(++def); continue; } // [VK] for (int i = 0; i < MAX_KEYNAME; ++i) { size_t keylen = _tcslen(KeyNames[i].name); if (!_tcsncmp(def, KeyNames[i].name, keylen)) { KeyBind keybind = {NONE, KeyNames[i].bVk}; *p++ = keybind; def += keylen; break; } } } } } }
void SjVirtKeybdKey::SetKey(const wxString& type__, const wxString& key) { wxString type(type__); bool shiftSet = FALSE; int shift = 0; if( type.Right(5) == wxT("shift") ) { shift = 1; shiftSet = TRUE; type = type.Left(type.Len()-5); } bool altSet = FALSE; int alt = 0; if( type.Left(3) == wxT("alt") ) { long l; if( type.Mid(3).ToLong(&l, 10) && l >= 1 && l < SJ_VK_MAX_ALT ) { alt = l; altSet = TRUE; } } if( !shiftSet && !altSet ) { return; // invalid key type } m_keys[shift][alt] = ParseKey(key, wxT(""), m_keyTitles[shift][alt], m_keyFlags[shift][alt]); }
// TODO: maybe also allow things like: // foo: [1 3 4] // i.e. a child on a single line static void ParseNextToken(TxtParser& parser) { TokenVal& tok = parser.tok; ZeroMemory(&tok, sizeof(TokenVal)); str::Slice& slice = parser.toParse; Again: // " foo: bar " // ^ tok.lineStart = slice.curr; slice.SkipWsUntilNewline(); if (slice.Finished()) { tok.type = TokenFinished; return; } // " foo: bar " // ^ // skip comments char c = slice.CurrChar(); if (IsCommentStartChar(c)) { slice.SkipUntil('\n'); slice.Skip(1); goto Again; } if ('[' == c || ']' == c) { tok.type = ('[' == c) ? TokenArrayStart : TokenClose; slice.ZeroCurr(); slice.Skip(1); slice.SkipWsUntilNewline(); if (slice.CurrChar() == '\n') { slice.ZeroCurr(); slice.Skip(1); } return; } if (ParseStructStart(parser)) return; tok.type = TokenString; ParseKey(parser); // " foo: bar" // ^ tok.valStart = slice.curr; char *origEnd = slice.curr; char *valEnd = UnescapeLineInPlace(origEnd, slice.end, parser.escapeChar); CrashIf((origEnd < slice.end) && (*origEnd != '\n')); if (valEnd < slice.end) *valEnd = 0; tok.valEnd = valEnd; slice.curr = origEnd; slice.ZeroCurr(); slice.Skip(1); return; }
bool ParseIfItem(FStrifeDialogueNode *node) { FStrifeDialogueItemCheck check; check.Item = NULL; check.Amount = -1; while (!sc.CheckToken('}')) { FName key = ParseKey(); switch(key) { case NAME_Item: check.Item = CheckActorType(key); break; case NAME_Count: // Not yet implemented in the engine. Todo later check.Amount = CheckInt(key); break; } } node->ItemCheck.Push(check); return true; }
static size_t DetectNrColsTable( FILE *tableFile) /* file to read */ { LOOK_UP_KEY k; long l =0; int nrCols=0; LexInstall(tableFile, "[]<>,"); while( (!ParseKey(&k, VS_UNDEFINED)) && !TEST_NOKEYREAD(k.t) ) { if (nrCols == 0) l = LexGetLineNr(); else { PRECOND(l!=0); if ( l != LexGetLineNr()) break; } nrCols++; } if (k.t == TEST_ERROR) return RetErrorNested(0,"line '%ld' column '%d':",l,nrCols+1); if (k.t == TEST_NOKEY && nrCols == 0) return RetErrorNested(0,"no columns found"); rewind(tableFile); return nrCols; }
bool CScriptKeyAlloc::ParseKey( LPCTSTR pszKey, LPCTSTR pszVal ) { ADDTOCALLSTACK("CScriptKeyAlloc::ParseKey"); ASSERT(pszKey); size_t lenkey = strlen( pszKey ); if ( ! lenkey ) { return ParseKey(pszVal); } ASSERT( lenkey < SCRIPT_MAX_LINE_LEN-2 ); size_t lenval = 0; if ( pszVal ) { lenval = strlen( pszVal ); } m_pszKey = GetKeyBufferRaw( lenkey + lenval + 1 ); strcpy( m_pszKey, pszKey ); m_pszArg = m_pszKey + lenkey; if ( pszVal ) { m_pszArg ++; lenval = m_Mem.GetDataLength() - 2; strcpylen( m_pszArg, pszVal, ( lenval - lenkey ) + 1 ); // strcpylen } return( true ); }
RegPathParam::RegPathParam(RegContext*pContext, string pValue, bool pIncludeValue, bool pOpen) { _context = pContext; _closeKey = false; if (pValue.find_first_of('\\') == std::string::npos) { _root = _context->rootKey; _path = wstring(_context->regPath.begin(), _context->regPath.end()); _key = _context->currentKey; _valueName = pValue; return; } if (pValue.find_first_of('###') == 0) { _root = _context->rootKey; _path = wstring(_context->regPath.begin(), _context->regPath.end()); _key = _context->currentKey; _valueName = pValue.substr(3, string::npos);; return; } string rootName = pValue.substr(0, pValue.find_first_of('\\')); _root = ParseKey(rootName.c_str()); pValue = pValue.substr(pValue.find_first_of('\\') + 1, string::npos); if (_root == NULL) { throw invalid_argument(rootName + " is not a valid root"); } string path; if (pIncludeValue){ if (pValue.find_last_of('\\') == std::string::npos) { throw invalid_argument("A full value path is in the form HKLM\PATH\ValueName"); } path = pValue.substr(0, pValue.find_last_of('\\')); _valueName = pValue.substr(pValue.find_last_of('\\') + 1, string::npos); }
bool ParseConversation() { const PClass *type = NULL; int dlgid = -1; unsigned int startpos = StrifeDialogues.Size(); while (!sc.CheckToken('}')) { bool block = false; FName key = ParseKey(true, &block); if (!block) { switch(key) { case NAME_Actor: type = CheckActorType(key); if (namespace_bits == St) { dlgid = CheckInt(key); } break; case NAME_Id: if (namespace_bits == Zd) { dlgid = CheckInt(key); } break; } } else { switch(key) { case NAME_Page: if (!ParsePage()) return false; break; default: sc.UnGet(); Skip(); } } } if (type == NULL && dlgid == 0) { sc.ScriptMessage("No valid actor type defined in conversation."); return false; } SetConversation(dlgid, type, startpos); for(;startpos < StrifeDialogues.Size(); startpos++) { StrifeDialogues[startpos]->SpeakerType = type; } return true; }
void SetHotKey (char *strKeys, HOTKEYS * hotkey) { char *p; char strKey[30]; int i, j; p = strKeys; while (*p == ' ') p++; i = 0; while (p[i] != ' ' && p[i] != '\0') i++; strncpy (strKey, p, i); strKey[i] = '\0'; p += i + 1; j = ParseKey (strKey); if (j != -1) hotkey[0] = j; if (j == -1) j = 0; else j = 1; i = 0; while (p[i] != ' ' && p[i] != '\0') i++; if (p[0]) { strncpy (strKey, p, i); strKey[i] = '\0'; i = ParseKey (strKey); if (i == -1) i = 0; } else i = 0; hotkey[j] = i; }
nsresult KeyMatchesLoadContextInfo(const nsACString &aKey, nsILoadContextInfo *aInfo, bool *_retval) { nsCOMPtr<nsILoadContextInfo> info = ParseKey(aKey); if (!info) { return NS_ERROR_FAILURE; } *_retval = info->Equals(aInfo); return NS_OK; }
SjVirtKeybdKey::SjVirtKeybdKey(const wxString& keyNormal) { for( int s = 0; s < SJ_VK_MAX_SHIFT; s++ ) { for( int a = 0; a < SJ_VK_MAX_ALT; a++ ) { m_keyFlags[s][a] = 0; } } m_keys[0][0] = ParseKey(keyNormal, wxT("spacer"), m_keyTitles[0][0], m_keyFlags[0][0]); m_relXPos = 0.0; m_relWidth = 1.0; }
void kexConsole::StickyKeyTick(void) { if(!bStickyActive) { int stickyTime = cvarStickyKeySpeed.GetInt(); if(stickyTime < 0) { stickyTime = 0; } if(bKeyHeld && ((sysMain.GetMS() - timePressed) >= stickyTime)) { bStickyActive = true; } } else { ParseKey(lastKeyPressed); } }
void MessagePackReader::ParseMap(size_t length) { log_debug("MessagePackReader::ParseMap, length=" << length); ResetToken(); handler_->StartMap(length); for (size_t i=0; i<length; i++) { ParseKey(); ParseStream(); if (i != (length-1)) handler_->MapSeparator(); } handler_->EndMap(length); }
//----------------------------------------------------------------------------------- void Console::Update(float deltaSeconds) { if (m_isActive) { m_timeSinceCursorBlink += deltaSeconds; if (*m_cursorPointer != CURSOR_CHARACTER) { m_characterAtCursor = *m_cursorPointer; } char currentChar = InputSystem::instance->GetLastPressedChar(); ParseKey(currentChar); if (m_timeSinceCursorBlink >= CURSOR_BLINK_RATE_SECONDS) { m_timeSinceCursorBlink = 0.0f; m_isCursorShowing = !m_isCursorShowing; *m_cursorPointer = m_isCursorShowing ? CURSOR_CHARACTER : m_characterAtCursor; } } }
void GUIKeyboard::LoadKeyLabels(xml_node<>* parent, int layout) { for (xml_node<>* child = parent->first_node(); child; child = child->next_sibling()) { std::string name = child->name(); if (name == "keylabel") { std::string keydef = LoadAttrString(child, "key", ""); Key tempkey; int dummyX; if (ParseKey(keydef.c_str(), tempkey, dummyX, 0, false) == 0) { KeyLabel keylabel; keylabel.key = tempkey.key; keylabel.layout_from = layout; keylabel.layout_to = tempkey.layout; keylabel.text = LoadAttrString(child, "text", ""); keylabel.image = LoadAttrImage(child, "resource"); mKeyLabels.push_back(keylabel); } else { LOGERR("Ignoring invalid keylabel in layout %d: '%s'.\n", layout, keydef.c_str()); } } } }
bool ParseCost(FStrifeDialogueReply *response) { FStrifeDialogueItemCheck check; check.Item = NULL; check.Amount = -1; while (!sc.CheckToken('}')) { FName key = ParseKey(); switch(key) { case NAME_Item: check.Item = CheckActorType(key); break; case NAME_Amount: check.Amount = CheckInt(key); break; } } response->ItemCheck.Push(check); return true; }
void ParseVertex(vertex_t *vt, vertexdata_t *vd) { vt->set(0, 0); vd->zCeiling = vd->zFloor = vd->flags = 0; sc.MustGetToken('{'); double x, y; while (!sc.CheckToken('}')) { FName key = ParseKey(); switch (key) { case NAME_X: x = CheckFloat(key); break; case NAME_Y: y = CheckFloat(key); break; case NAME_ZCeiling: vd->zCeiling = CheckFloat(key); vd->flags |= VERTEXFLAG_ZCeilingEnabled; break; case NAME_ZFloor: vd->zFloor = CheckFloat(key); vd->flags |= VERTEXFLAG_ZFloorEnabled; break; default: break; } } vt->set(x, y); }
bool kexConsole::ProcessInput(const event_t *ev) { if(ev->type == ev_mousedown || ev->type == ev_mouseup || ev->type == ev_mouse) { return false; } if(ev->type == ev_mousewheel && state == CON_STATE_DOWN) { switch(ev->data1) { case KM_BUTTON_SCROLL_UP: LineScroll(1); break; case KM_BUTTON_SCROLL_DOWN: LineScroll(0); break; } return true; } CheckShift(ev); CheckStickyKeys(ev); int c = ev->data1; switch(state) { case CON_STATE_DOWN: if(ev->type == ev_keydown) { switch(c) { case KKEY_BACKQUOTE: state = CON_STATE_UP; inputSystem->MouseCenter(); return true; case KKEY_RETURN: ParseInput(); return true; case KKEY_UP: GetHistory(false); return true; case KKEY_DOWN: GetHistory(true); return true; case KKEY_TAB: cvarManager.AutoComplete(typeStr); command.AutoComplete(typeStr); return true; default: ParseKey(c); return true; } return false; } break; case CON_STATE_UP: if(ev->type == ev_keydown) { switch(c) { case KKEY_BACKQUOTE: state = CON_STATE_DOWN; return true; default: break; } return false; } break; default: return false; } return false; }
bool ParsePage() { FStrifeDialogueNode *node = new FStrifeDialogueNode; FStrifeDialogueReply **replyptr = &node->Children; memset(node, 0, sizeof(*node)); //node->ItemCheckCount[0] = node->ItemCheckCount[1] = node->ItemCheckCount[2] = -1; node->ThisNodeNum = StrifeDialogues.Push(node); node->ItemCheckNode = -1; FString SpeakerName; FString Dialogue; while (!sc.CheckToken('}')) { bool block = false; FName key = ParseKey(true, &block); if (!block) { switch(key) { case NAME_Name: SpeakerName = CheckString(key); break; case NAME_Panel: node->Backdrop = TexMan.CheckForTexture (CheckString(key), FTexture::TEX_MiscPatch); break; case NAME_Voice: { const char * name = CheckString(key); if (name[0] != 0) { FString soundname = "svox/"; soundname += name; node->SpeakerVoice = FSoundID(S_FindSound(soundname)); if (node->SpeakerVoice == 0 && namespace_bits == Zd) { node->SpeakerVoice = FSoundID(S_FindSound(name)); } } } break; case NAME_Dialog: Dialogue = CheckString(key); break; case NAME_Drop: node->DropType = CheckActorType(key); break; case NAME_Link: node->ItemCheckNode = CheckInt(key); break; } } else { switch(key) { case NAME_Ifitem: if (!ParseIfItem(node)) return false; break; case NAME_Choice: if (!ParseChoice(replyptr)) return false; break; default: sc.UnGet(); Skip(); } } } node->SpeakerName = ncopystring(SpeakerName); node->Dialogue = ncopystring(Dialogue); return true; }
/* kk * returns allocated list of records, NULL in case of error (stored * in ErrorNested */ static LOOK_UP_KEY *ReadLookupRecs( size_t *nrCols, /* write-only */ size_t *nrRecs, /* write-only */ size_t nrKeysExp,/* numbers of keys expected, only relevant * if vsTargetValue != VS_UNDEFINED * this is exclusive the targetColumn */ CSF_VS vsTargetVal, /* if VS_UNDEFINED then skip test on exact number * of columns (= nrKeysExp+1) */ FILE *tableFile) { size_t n,nrK,c = DetectNrColsTable(tableFile); LOOK_UP_KEY *k = NULL; long recStartAt=0; if (c == 0) goto error; if (c == 1 && vsTargetVal != VS_UNDEFINED ) { ErrorNested("only 1 column found"); return NULL; } if (vsTargetVal != VS_UNDEFINED && c != (nrKeysExp+1)) { ErrorNested("contains %s columns ('%d' read,'%d' expected)", (c < (nrKeysExp+1) ? "not enough" : "too many"), c, nrKeysExp+1); goto error; } LexInstall(tableFile, "[]<>,"); for (nrK = n = 0; /* break from code */ ; n++) { CSF_VS vs = VS_UNDEFINED; if (n == nrK) { nrK += 40; if (ChkReallocFree((void **)&k,nrK * sizeof(LOOK_UP_KEY))) return NULL; } if (vsTargetVal != VS_UNDEFINED && (n%c) == nrKeysExp) vs = vsTargetVal; ParseKey(k+n, vs); if (k[n].t == TEST_NOKEY) { if ( (n%c)==0 ) break; else goto notEnough; } if (k[n].t == TEST_ERROR) { ErrorNested("while reading at line '%ld' column '%d'", LexGetLineNr(), (n%c)+1); goto error; } if (vsTargetVal != VS_UNDEFINED && (n%c) == nrKeysExp && k[n].t != TEST_ONE ) { ErrorNested( "value field at line '%ld' column '%d' is not a single value" , LexGetLineNr(), (n%c)+1); goto error; } if ( (n%c)==0) /* start new record */ { if (recStartAt == LexGetLineNr()) /* prev had more */ { ErrorNested( "Too many columns on line '%ld', expected '%d' columns", recStartAt,c); goto error; } recStartAt = LexGetLineNr(); } else /* add to this record */ { if (recStartAt != LexGetLineNr()) /* this does not have enough */ { notEnough: ErrorNested( "Not enough columns on line '%ld', expected '%d' columns", recStartAt,c); goto error; } } } /* eofor */ POSTCOND( (n % c) == 0); *nrCols = c; *nrRecs = n/c; return k; error: Free(k); return NULL; }
bool ParseChoice(FStrifeDialogueReply **&replyptr) { FStrifeDialogueReply *reply = new FStrifeDialogueReply; memset(reply, 0, sizeof(*reply)); reply->Next = *replyptr; *replyptr = reply; replyptr = &reply->Next; FString ReplyString; FString QuickYes; FString QuickNo; FString LogString; bool closeDialog = false; reply->NeedsGold = false; while (!sc.CheckToken('}')) { bool block = false; FName key = ParseKey(true, &block); if (!block) { switch(key) { case NAME_Text: ReplyString = CheckString(key); break; case NAME_Displaycost: reply->NeedsGold = CheckBool(key); break; case NAME_Yesmessage: QuickYes = CheckString(key); //if (!QuickYes.Compare("_")) QuickYes = ""; break; case NAME_Nomessage: QuickNo = CheckString(key); break; case NAME_Log: if (namespace_bits == St) { const char *s = CheckString(key); if(strlen(s) < 4 || strnicmp(s, "LOG", 3) != 0) { sc.ScriptMessage("Log must be in the format of LOG# to compile, ignoring."); } else { reply->LogNumber = atoi(s + 3); } } else { LogString = CheckString(key); } break; case NAME_Giveitem: reply->GiveType = CheckActorType(key); break; case NAME_Nextpage: reply->NextNode = CheckInt(key); break; case NAME_Closedialog: closeDialog = CheckBool(key); break; case NAME_Special: reply->ActionSpecial = CheckInt(key); if (reply->ActionSpecial < 0 || reply->ActionSpecial > 255) reply->ActionSpecial = 0; break; case NAME_Arg0: case NAME_Arg1: case NAME_Arg2: case NAME_Arg3: case NAME_Arg4: reply->Args[int(key)-int(NAME_Arg0)] = CheckInt(key); break; } } else { switch(key) { case NAME_Cost: ParseCost(reply); break; default: sc.UnGet(); Skip(); } } } // Todo: Finalize if (reply->ItemCheck.Size() > 0) { if (reply->ItemCheck[0].Amount <= 0) reply->NeedsGold = false; } reply->Reply = ncopystring(ReplyString); reply->QuickYes = ncopystring(QuickYes); if (reply->ItemCheck.Size() > 0 && reply->ItemCheck[0].Item != NULL) { reply->QuickNo = ncopystring(QuickNo); } else { reply->QuickNo = NULL; } reply->LogString = ncopystring(LogString); if(!closeDialog) reply->NextNode *= -1; return true; }
void ParseLinedef(line_t *ld, int index) { bool passuse = false; bool strifetrans = false; bool strifetrans2 = false; FString arg0str, arg1str; memset(ld, 0, sizeof(*ld)); ld->Alpha = FRACUNIT; ld->id = -1; ld->sidedef[0] = ld->sidedef[1] = NULL; if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX; if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX; if (level.flags2 & LEVEL2_CHECKSWITCHRANGE) ld->flags |= ML_CHECKSWITCHRANGE; sc.MustGetToken('{'); while (!sc.CheckToken('}')) { FName key = ParseKey(); // This switch contains all keys of the UDMF base spec switch(key) { case NAME_V1: ld->v1 = (vertex_t*)(intptr_t)CheckInt(key); // must be relocated later continue; case NAME_V2: ld->v2 = (vertex_t*)(intptr_t)CheckInt(key); // must be relocated later continue; case NAME_Special: ld->special = CheckInt(key); if (namespc == NAME_Hexen) { if (ld->special < 0 || ld->special > 140 || !HexenLineSpecialOk[ld->special]) ld->special = 0; // NULL all specials which don't exist in Hexen } continue; case NAME_Id: ld->id = CheckInt(key); continue; case NAME_Sidefront: ld->sidedef[0] = (side_t*)(intptr_t)(1 + CheckInt(key)); continue; case NAME_Sideback: ld->sidedef[1] = (side_t*)(intptr_t)(1 + CheckInt(key)); continue; case NAME_Arg0: case NAME_Arg1: case NAME_Arg2: case NAME_Arg3: case NAME_Arg4: ld->args[int(key)-int(NAME_Arg0)] = CheckInt(key); continue; case NAME_Arg0Str: CHECK_N(Zd); arg0str = CheckString(key); continue; case NAME_Arg1Str: CHECK_N(Zd); arg1str = CheckString(key); continue; case NAME_Blocking: Flag(ld->flags, ML_BLOCKING, key); continue; case NAME_Blockmonsters: Flag(ld->flags, ML_BLOCKMONSTERS, key); continue; case NAME_Twosided: Flag(ld->flags, ML_TWOSIDED, key); continue; case NAME_Dontpegtop: Flag(ld->flags, ML_DONTPEGTOP, key); continue; case NAME_Dontpegbottom: Flag(ld->flags, ML_DONTPEGBOTTOM, key); continue; case NAME_Secret: Flag(ld->flags, ML_SECRET, key); continue; case NAME_Blocksound: Flag(ld->flags, ML_SOUNDBLOCK, key); continue; case NAME_Dontdraw: Flag(ld->flags, ML_DONTDRAW, key); continue; case NAME_Mapped: Flag(ld->flags, ML_MAPPED, key); continue; case NAME_Jumpover: CHECK_N(St | Zd | Zdt | Va) Flag(ld->flags, ML_RAILING, key); continue; case NAME_Blockfloaters: CHECK_N(St | Zd | Zdt | Va) Flag(ld->flags, ML_BLOCK_FLOATERS, key); continue; case NAME_Translucent: CHECK_N(St | Zd | Zdt | Va) strifetrans = CheckBool(key); continue; case NAME_Transparent: CHECK_N(St | Zd | Zdt | Va) strifetrans2 = CheckBool(key); continue; case NAME_Passuse: CHECK_N(Dm | Zd | Zdt | Va) passuse = CheckBool(key); continue; default: break; } // This switch contains all keys of the UDMF base spec which only apply to Hexen format specials if (!isTranslated) switch (key) { case NAME_Playercross: Flag(ld->activation, SPAC_Cross, key); continue; case NAME_Playeruse: Flag(ld->activation, SPAC_Use, key); continue; case NAME_Playeruseback: Flag(ld->activation, SPAC_UseBack, key); continue; case NAME_Monstercross: Flag(ld->activation, SPAC_MCross, key); continue; case NAME_Impact: Flag(ld->activation, SPAC_Impact, key); continue; case NAME_Playerpush: Flag(ld->activation, SPAC_Push, key); continue; case NAME_Missilecross: Flag(ld->activation, SPAC_PCross, key); continue; case NAME_Monsteruse: Flag(ld->activation, SPAC_MUse, key); continue; case NAME_Monsterpush: Flag(ld->activation, SPAC_MPush, key); continue; case NAME_Repeatspecial: Flag(ld->flags, ML_REPEAT_SPECIAL, key); continue; default: break; } // This switch contains all keys which are ZDoom specific if (namespace_bits & (Zd|Zdt|Va)) switch(key) { case NAME_Alpha: ld->Alpha = CheckFixed(key); continue; case NAME_Renderstyle: { const char *str = CheckString(key); if (!stricmp(str, "translucent")) ld->flags &= ~ML_ADDTRANS; else if (!stricmp(str, "add")) ld->flags |= ML_ADDTRANS; else sc.ScriptMessage("Unknown value \"%s\" for 'renderstyle'\n", str); continue; } case NAME_Anycross: Flag(ld->activation, SPAC_AnyCross, key); continue; case NAME_Monsteractivate: Flag(ld->flags, ML_MONSTERSCANACTIVATE, key); continue; case NAME_Blockplayers: Flag(ld->flags, ML_BLOCK_PLAYERS, key); continue; case NAME_Blockeverything: Flag(ld->flags, ML_BLOCKEVERYTHING, key); continue; case NAME_Zoneboundary: Flag(ld->flags, ML_ZONEBOUNDARY, key); continue; case NAME_Clipmidtex: Flag(ld->flags, ML_CLIP_MIDTEX, key); continue; case NAME_Wrapmidtex: Flag(ld->flags, ML_WRAP_MIDTEX, key); continue; case NAME_Midtex3d: Flag(ld->flags, ML_3DMIDTEX, key); continue; case NAME_Checkswitchrange: Flag(ld->flags, ML_CHECKSWITCHRANGE, key); continue; case NAME_Firstsideonly: Flag(ld->flags, ML_FIRSTSIDEONLY, key); continue; case NAME_blockprojectiles: Flag(ld->flags, ML_BLOCKPROJECTILE, key); continue; case NAME_blockuse: Flag(ld->flags, ML_BLOCKUSE, key); continue; case NAME_blocksight: Flag(ld->flags, ML_BLOCKSIGHT, key); continue; case NAME_blockhitscan: Flag(ld->flags, ML_BLOCKHITSCAN, key); continue; // [Dusk] lock number case NAME_Locknumber: ld->locknumber = CheckInt(key); continue; default: break; } if (!strnicmp("user_", key.GetChars(), 5)) { AddUserKey(key, UDMF_Line, index); } } if (isTranslated) { int saved = ld->flags; maplinedef_t mld; memset(&mld, 0, sizeof(mld)); mld.special = ld->special; mld.tag = ld->id; P_TranslateLineDef(ld, &mld); ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY)); } if (passuse && (ld->activation & SPAC_Use)) { ld->activation = (ld->activation & ~SPAC_Use) | SPAC_UseThrough; } if (strifetrans && ld->Alpha == FRACUNIT) { ld->Alpha = FRACUNIT * 3/4; } if (strifetrans2 && ld->Alpha == FRACUNIT) { ld->Alpha = FRACUNIT * 1/4; } if (ld->sidedef[0] == NULL) { ld->sidedef[0] = (side_t*)(intptr_t)(1); Printf("Line %d has no first side.\n", index); } if (arg0str.IsNotEmpty() && (P_IsACSSpecial(ld->special) || ld->special == 0)) { ld->args[0] = -FName(arg0str); } if (arg1str.IsNotEmpty() && (P_IsThingSpecial(ld->special) || ld->special == 0)) { ld->args[1] = -FName(arg1str); } }
void ParseThing(FMapThing *th) { FString arg0str, arg1str; memset(th, 0, sizeof(*th)); th->gravity = FRACUNIT; th->RenderStyle = STYLE_Count; th->alpha = -1; th->health = 1; sc.MustGetToken('{'); while (!sc.CheckToken('}')) { FName key = ParseKey(); switch(key) { case NAME_Id: th->thingid = CheckInt(key); break; case NAME_X: th->x = CheckFixed(key); break; case NAME_Y: th->y = CheckFixed(key); break; case NAME_Height: th->z = CheckFixed(key); break; case NAME_Angle: th->angle = (short)CheckInt(key); break; case NAME_Type: th->type = (short)CheckInt(key); break; case NAME_Conversation: CHECK_N(Zd | Zdt) th->Conversation = CheckInt(key); break; case NAME_Special: CHECK_N(Hx | Zd | Zdt | Va) th->special = CheckInt(key); break; case NAME_Gravity: CHECK_N(Zd | Zdt) th->gravity = CheckFixed(key); break; case NAME_Arg0: case NAME_Arg1: case NAME_Arg2: case NAME_Arg3: case NAME_Arg4: CHECK_N(Hx | Zd | Zdt | Va) th->args[int(key)-int(NAME_Arg0)] = CheckInt(key); break; case NAME_Arg0Str: CHECK_N(Zd); arg0str = CheckString(key); break; case NAME_Arg1Str: CHECK_N(Zd); arg1str = CheckString(key); break; case NAME_Skill1: case NAME_Skill2: case NAME_Skill3: case NAME_Skill4: case NAME_Skill5: case NAME_Skill6: case NAME_Skill7: case NAME_Skill8: case NAME_Skill9: case NAME_Skill10: case NAME_Skill11: case NAME_Skill12: case NAME_Skill13: case NAME_Skill14: case NAME_Skill15: case NAME_Skill16: if (CheckBool(key)) th->SkillFilter |= (1<<(int(key)-NAME_Skill1)); else th->SkillFilter &= ~(1<<(int(key)-NAME_Skill1)); break; case NAME_Class1: case NAME_Class2: case NAME_Class3: case NAME_Class4: case NAME_Class5: case NAME_Class6: case NAME_Class7: case NAME_Class8: case NAME_Class9: case NAME_Class10: case NAME_Class11: case NAME_Class12: case NAME_Class13: case NAME_Class14: case NAME_Class15: case NAME_Class16: CHECK_N(Hx | Zd | Zdt | Va) if (CheckBool(key)) th->ClassFilter |= (1<<(int(key)-NAME_Class1)); else th->ClassFilter &= ~(1<<(int(key)-NAME_Class1)); break; case NAME_Ambush: Flag(th->flags, MTF_AMBUSH, key); break; case NAME_Dormant: CHECK_N(Hx | Zd | Zdt | Va) Flag(th->flags, MTF_DORMANT, key); break; case NAME_Single: Flag(th->flags, MTF_SINGLE, key); break; case NAME_Coop: Flag(th->flags, MTF_COOPERATIVE, key); break; case NAME_Dm: Flag(th->flags, MTF_DEATHMATCH, key); break; case NAME_Translucent: CHECK_N(St | Zd | Zdt | Va) Flag(th->flags, MTF_SHADOW, key); break; case NAME_Invisible: CHECK_N(St | Zd | Zdt | Va) Flag(th->flags, MTF_ALTSHADOW, key); break; case NAME_Friend: // This maps to Strife's friendly flag CHECK_N(Dm | Zd | Zdt | Va) Flag(th->flags, MTF_FRIENDLY, key); break; case NAME_Strifeally: CHECK_N(St | Zd | Zdt | Va) Flag(th->flags, MTF_FRIENDLY, key); break; case NAME_Standing: CHECK_N(St | Zd | Zdt | Va) Flag(th->flags, MTF_STANDSTILL, key); break; case NAME_Countsecret: CHECK_N(Zd | Zdt | Va) Flag(th->flags, MTF_SECRET, key); break; case NAME_Renderstyle: { FName style = CheckString(key); switch (style) { case NAME_None: th->RenderStyle = STYLE_None; break; case NAME_Normal: th->RenderStyle = STYLE_Normal; break; case NAME_Fuzzy: th->RenderStyle = STYLE_Fuzzy; break; case NAME_SoulTrans: th->RenderStyle = STYLE_SoulTrans; break; case NAME_OptFuzzy: th->RenderStyle = STYLE_OptFuzzy; break; case NAME_Stencil: th->RenderStyle = STYLE_Stencil; break; case NAME_AddStencil: th->RenderStyle = STYLE_AddStencil; break; case NAME_Translucent: th->RenderStyle = STYLE_Translucent; break; case NAME_Add: case NAME_Additive: th->RenderStyle = STYLE_Add; break; case NAME_Shaded: th->RenderStyle = STYLE_Shaded; break; case NAME_AddShaded: th->RenderStyle = STYLE_AddShaded; break; case NAME_TranslucentStencil: th->RenderStyle = STYLE_TranslucentStencil; break; case NAME_Shadow: th->RenderStyle = STYLE_Shadow; break; case NAME_Subtract: case NAME_Subtractive: th->RenderStyle = STYLE_Subtract; break; default: break; } } break; case NAME_Alpha: th->alpha = CheckFixed(key); break; case NAME_FillColor: th->fillcolor = CheckInt(key); case NAME_Health: th->health = CheckInt(key); break; case NAME_Score: th->score = CheckInt(key); break; case NAME_Pitch: th->pitch = (short)CheckInt(key); break; case NAME_Roll: th->roll = (short)CheckInt(key); break; case NAME_ScaleX: th->scaleX = CheckFixed(key); break; case NAME_ScaleY: th->scaleY = CheckFixed(key); break; case NAME_Scale: th->scaleX = th->scaleY = CheckFixed(key); break; default: if (0 == strnicmp("user_", key.GetChars(), 5)) { // Custom user key - Sets an actor's user variable directly FMapThingUserData ud; ud.Property = key; ud.Value = CheckInt(key); MapThingsUserData.Push(ud); } break; } } if (arg0str.IsNotEmpty() && (P_IsACSSpecial(th->special) || th->special == 0)) { th->args[0] = -FName(arg0str); } if (arg1str.IsNotEmpty() && (P_IsThingSpecial(th->special) || th->special == 0)) { th->args[1] = -FName(arg1str); } // Thing specials are only valid in namespaces with Hexen-type specials // and in ZDoomTranslated - which will use the translator on them. if (namespc == NAME_ZDoomTranslated) { maplinedef_t mld; line_t ld; if (th->special != 0) // if special is 0, keep the args (e.g. for bridge things) { // The trigger type is ignored here. mld.flags = 0; mld.special = th->special; mld.tag = th->args[0]; P_TranslateLineDef(&ld, &mld); th->special = ld.special; memcpy(th->args, ld.args, sizeof (ld.args)); } } else if (isTranslated) { th->special = 0; memset(th->args, 0, sizeof (th->args)); } }
void ParseSector(sector_t *sec, int index) { int lightcolor = -1; int fadecolor = -1; int desaturation = -1; int fplaneflags = 0, cplaneflags = 0; double fp[4] = { 0 }, cp[4] = { 0 }; memset(sec, 0, sizeof(*sec)); sec->lightlevel = 160; sec->SetXScale(sector_t::floor, FRACUNIT); // [RH] floor and ceiling scaling sec->SetYScale(sector_t::floor, FRACUNIT); sec->SetXScale(sector_t::ceiling, FRACUNIT); sec->SetYScale(sector_t::ceiling, FRACUNIT); sec->SetAlpha(sector_t::floor, FRACUNIT); sec->SetAlpha(sector_t::ceiling, FRACUNIT); sec->thinglist = NULL; sec->touching_thinglist = NULL; // phares 3/14/98 sec->seqType = (level.flags & LEVEL_SNDSEQTOTALCTRL) ? 0 : -1; sec->nextsec = -1; //jff 2/26/98 add fields to support locking out sec->prevsec = -1; // stair retriggering until build completes sec->heightsec = NULL; // sector used to get floor and ceiling height sec->sectornum = index; if (floordrop) sec->Flags = SECF_FLOORDROP; // killough 3/7/98: end changes sec->gravity = 1.f; // [RH] Default sector gravity of 1.0 sec->ZoneNumber = 0xFFFF; // killough 8/28/98: initialize all sectors to normal friction sec->friction = ORIG_FRICTION; sec->movefactor = ORIG_FRICTION_FACTOR; sc.MustGetToken('{'); while (!sc.CheckToken('}')) { FName key = ParseKey(); switch(key) { case NAME_Heightfloor: sec->SetPlaneTexZ(sector_t::floor, CheckInt(key) << FRACBITS); continue; case NAME_Heightceiling: sec->SetPlaneTexZ(sector_t::ceiling, CheckInt(key) << FRACBITS); continue; case NAME_Texturefloor: SetTexture(sec, index, sector_t::floor, CheckString(key), missingTex, false); continue; case NAME_Textureceiling: SetTexture(sec, index, sector_t::ceiling, CheckString(key), missingTex, false); continue; case NAME_Lightlevel: sec->lightlevel = sector_t::ClampLight(CheckInt(key)); continue; case NAME_Special: sec->special = (short)CheckInt(key); if (isTranslated) sec->special = P_TranslateSectorSpecial(sec->special); else if (namespc == NAME_Hexen) { if (sec->special < 0 || sec->special > 255 || !HexenSectorSpecialOk[sec->special]) sec->special = 0; // NULL all unknown specials } continue; case NAME_Id: sec->tag = (short)CheckInt(key); continue; default: break; } if (namespace_bits & (Zd|Zdt|Va)) switch(key) { case NAME_Xpanningfloor: sec->SetXOffset(sector_t::floor, CheckFixed(key)); continue; case NAME_Ypanningfloor: sec->SetYOffset(sector_t::floor, CheckFixed(key)); continue; case NAME_Xpanningceiling: sec->SetXOffset(sector_t::ceiling, CheckFixed(key)); continue; case NAME_Ypanningceiling: sec->SetYOffset(sector_t::ceiling, CheckFixed(key)); continue; case NAME_Xscalefloor: sec->SetXScale(sector_t::floor, CheckFixed(key)); continue; case NAME_Yscalefloor: sec->SetYScale(sector_t::floor, CheckFixed(key)); continue; case NAME_Xscaleceiling: sec->SetXScale(sector_t::ceiling, CheckFixed(key)); continue; case NAME_Yscaleceiling: sec->SetYScale(sector_t::ceiling, CheckFixed(key)); continue; case NAME_Rotationfloor: sec->SetAngle(sector_t::floor, CheckAngle(key)); continue; case NAME_Rotationceiling: sec->SetAngle(sector_t::ceiling, CheckAngle(key)); continue; case NAME_Lightfloor: sec->SetPlaneLight(sector_t::floor, CheckInt(key)); continue; case NAME_Lightceiling: sec->SetPlaneLight(sector_t::ceiling, CheckInt(key)); continue; case NAME_Alphafloor: sec->SetAlpha(sector_t::floor, CheckFixed(key)); continue; case NAME_Alphaceiling: sec->SetAlpha(sector_t::ceiling, CheckFixed(key)); continue; case NAME_Renderstylefloor: { const char *str = CheckString(key); if (!stricmp(str, "translucent")) sec->ChangeFlags(sector_t::floor, PLANEF_ADDITIVE, 0); else if (!stricmp(str, "add")) sec->ChangeFlags(sector_t::floor, 0, PLANEF_ADDITIVE); else sc.ScriptMessage("Unknown value \"%s\" for 'renderstylefloor'\n", str); continue; } case NAME_Renderstyleceiling: { const char *str = CheckString(key); if (!stricmp(str, "translucent")) sec->ChangeFlags(sector_t::ceiling, PLANEF_ADDITIVE, 0); else if (!stricmp(str, "add")) sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ADDITIVE); else sc.ScriptMessage("Unknown value \"%s\" for 'renderstyleceiling'\n", str); continue; } case NAME_Lightfloorabsolute: if (CheckBool(key)) sec->ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); else sec->ChangeFlags(sector_t::floor, PLANEF_ABSLIGHTING, 0); continue; case NAME_Lightceilingabsolute: if (CheckBool(key)) sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); else sec->ChangeFlags(sector_t::ceiling, PLANEF_ABSLIGHTING, 0); continue; case NAME_Gravity: sec->gravity = float(CheckFloat(key)); continue; case NAME_Lightcolor: lightcolor = CheckInt(key); continue; case NAME_Fadecolor: fadecolor = CheckInt(key); continue; case NAME_Desaturation: desaturation = int(255*CheckFloat(key)); continue; case NAME_Silent: Flag(sec->Flags, SECF_SILENT, key); continue; case NAME_NoRespawn: Flag(sec->Flags, SECF_NORESPAWN, key); continue; case NAME_Nofallingdamage: Flag(sec->Flags, SECF_NOFALLINGDAMAGE, key); continue; case NAME_Dropactors: Flag(sec->Flags, SECF_FLOORDROP, key); continue; case NAME_SoundSequence: sec->SeqName = CheckString(key); sec->seqType = -1; continue; case NAME_hidden: Flag(sec->MoreFlags, SECF_HIDDEN, key); break; case NAME_Waterzone: Flag(sec->MoreFlags, SECF_UNDERWATER, key); break; case NAME_floorplane_a: fplaneflags |= 1; fp[0] = CheckFloat(key); break; case NAME_floorplane_b: fplaneflags |= 2; fp[1] = CheckFloat(key); break; case NAME_floorplane_c: fplaneflags |= 4; fp[2] = CheckFloat(key); break; case NAME_floorplane_d: fplaneflags |= 8; fp[3] = CheckFloat(key); break; case NAME_ceilingplane_a: cplaneflags |= 1; cp[0] = CheckFloat(key); break; case NAME_ceilingplane_b: cplaneflags |= 2; cp[1] = CheckFloat(key); break; case NAME_ceilingplane_c: cplaneflags |= 4; cp[2] = CheckFloat(key); break; case NAME_ceilingplane_d: cplaneflags |= 8; cp[3] = CheckFloat(key); break; default: break; } if (!strnicmp("user_", key.GetChars(), 5)) { AddUserKey(key, UDMF_Sector, index); } } sec->secretsector = !!(sec->special&SECRET_MASK); // Reset the planes to their defaults if not all of the plane equation's parameters were found. if (fplaneflags != 15) { sec->floorplane.a = sec->floorplane.b = 0; sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor); sec->floorplane.c = FRACUNIT; sec->floorplane.ic = FRACUNIT; } else { double ulen = TVector3<double>(fp[0], fp[1], fp[2]).Length(); // normalize the vector, it must have a length of 1 sec->floorplane.a = FLOAT2FIXED(fp[0] / ulen); sec->floorplane.b = FLOAT2FIXED(fp[1] / ulen); sec->floorplane.c = FLOAT2FIXED(fp[2] / ulen); sec->floorplane.d = FLOAT2FIXED(fp[3] / ulen); sec->floorplane.ic = FLOAT2FIXED(ulen / fp[2]); } if (cplaneflags != 15) { sec->ceilingplane.a = sec->ceilingplane.b = 0; sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling); sec->ceilingplane.c = -FRACUNIT; sec->ceilingplane.ic = -FRACUNIT; } else { double ulen = TVector3<double>(cp[0], cp[1], cp[2]).Length(); // normalize the vector, it must have a length of 1 sec->floorplane.a = FLOAT2FIXED(cp[0] / ulen); sec->floorplane.b = FLOAT2FIXED(cp[1] / ulen); sec->floorplane.c = FLOAT2FIXED(cp[2] / ulen); sec->floorplane.d = FLOAT2FIXED(cp[3] / ulen); sec->floorplane.ic = FLOAT2FIXED(ulen / cp[2]); } if (lightcolor == -1 && fadecolor == -1 && desaturation == -1) { // [RH] Sectors default to white light with the default fade. // If they are outside (have a sky ceiling), they use the outside fog. if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special&0xff) == Sector_Outside)) { if (fogMap == NULL) fogMap = GetSpecialLights (PalEntry (255,255,255), level.outsidefog, 0); sec->ColorMap = fogMap; } else { if (normMap == NULL) normMap = GetSpecialLights (PalEntry (255,255,255), level.fadeto, NormalLight.Desaturate); sec->ColorMap = normMap; } } else { if (lightcolor == -1) lightcolor = PalEntry(255,255,255); if (fadecolor == -1) { if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special&0xff) == Sector_Outside)) fadecolor = level.outsidefog; else fadecolor = level.fadeto; } if (desaturation == -1) desaturation = NormalLight.Desaturate; sec->ColorMap = GetSpecialLights (lightcolor, fadecolor, desaturation); } }
void ParseSector(sector_t *sec, int index) { int lightcolor = -1; int fadecolor = -1; int desaturation = -1; int fplaneflags = 0, cplaneflags = 0; double fp[4] = { 0 }, cp[4] = { 0 }; FString tagstring; memset(sec, 0, sizeof(*sec)); sec->lightlevel = 160; sec->SetXScale(sector_t::floor, 1.); // [RH] floor and ceiling scaling sec->SetYScale(sector_t::floor, 1.); sec->SetXScale(sector_t::ceiling, 1.); sec->SetYScale(sector_t::ceiling, 1.); sec->SetAlpha(sector_t::floor, 1.); sec->SetAlpha(sector_t::ceiling, 1.); sec->thinglist = NULL; sec->touching_thinglist = NULL; // phares 3/14/98 sec->render_thinglist = NULL; sec->seqType = (level.flags & LEVEL_SNDSEQTOTALCTRL) ? 0 : -1; sec->nextsec = -1; //jff 2/26/98 add fields to support locking out sec->prevsec = -1; // stair retriggering until build completes sec->heightsec = NULL; // sector used to get floor and ceiling height sec->sectornum = index; sec->damageinterval = 32; sec->terrainnum[sector_t::ceiling] = sec->terrainnum[sector_t::floor] = -1; if (floordrop) sec->Flags = SECF_FLOORDROP; // killough 3/7/98: end changes sec->gravity = 1.; // [RH] Default sector gravity of 1.0 sec->ZoneNumber = 0xFFFF; // killough 8/28/98: initialize all sectors to normal friction sec->friction = ORIG_FRICTION; sec->movefactor = ORIG_FRICTION_FACTOR; sc.MustGetToken('{'); while (!sc.CheckToken('}')) { FName key = ParseKey(); switch(key) { case NAME_Heightfloor: sec->SetPlaneTexZ(sector_t::floor, CheckFloat(key)); continue; case NAME_Heightceiling: sec->SetPlaneTexZ(sector_t::ceiling, CheckFloat(key)); continue; case NAME_Texturefloor: SetTexture(sec, index, sector_t::floor, CheckString(key), missingTex, false); continue; case NAME_Textureceiling: SetTexture(sec, index, sector_t::ceiling, CheckString(key), missingTex, false); continue; case NAME_Lightlevel: sec->lightlevel = sector_t::ClampLight(CheckInt(key)); continue; case NAME_Special: sec->special = (short)CheckInt(key); if (isTranslated) sec->special = P_TranslateSectorSpecial(sec->special); else if (namespc == NAME_Hexen) { if (sec->special < 0 || sec->special > 255 || !HexenSectorSpecialOk[sec->special]) sec->special = 0; // NULL all unknown specials } continue; case NAME_Id: tagManager.AddSectorTag(index, CheckInt(key)); continue; default: break; } if (namespace_bits & (Zd|Zdt|Va)) switch(key) { case NAME_Xpanningfloor: sec->SetXOffset(sector_t::floor, CheckFloat(key)); continue; case NAME_Ypanningfloor: sec->SetYOffset(sector_t::floor, CheckFloat(key)); continue; case NAME_Xpanningceiling: sec->SetXOffset(sector_t::ceiling, CheckFloat(key)); continue; case NAME_Ypanningceiling: sec->SetYOffset(sector_t::ceiling, CheckFloat(key)); continue; case NAME_Xscalefloor: sec->SetXScale(sector_t::floor, CheckFloat(key)); continue; case NAME_Yscalefloor: sec->SetYScale(sector_t::floor, CheckFloat(key)); continue; case NAME_Xscaleceiling: sec->SetXScale(sector_t::ceiling, CheckFloat(key)); continue; case NAME_Yscaleceiling: sec->SetYScale(sector_t::ceiling, CheckFloat(key)); continue; case NAME_Rotationfloor: sec->SetAngle(sector_t::floor, CheckAngle(key)); continue; case NAME_Rotationceiling: sec->SetAngle(sector_t::ceiling, CheckAngle(key)); continue; case NAME_Lightfloor: sec->SetPlaneLight(sector_t::floor, CheckInt(key)); continue; case NAME_Lightceiling: sec->SetPlaneLight(sector_t::ceiling, CheckInt(key)); continue; case NAME_Alphafloor: sec->SetAlpha(sector_t::floor, CheckFloat(key)); continue; case NAME_Alphaceiling: sec->SetAlpha(sector_t::ceiling, CheckFloat(key)); continue; case NAME_Renderstylefloor: { const char *str = CheckString(key); if (!stricmp(str, "translucent")) sec->ChangeFlags(sector_t::floor, PLANEF_ADDITIVE, 0); else if (!stricmp(str, "add")) sec->ChangeFlags(sector_t::floor, 0, PLANEF_ADDITIVE); else sc.ScriptMessage("Unknown value \"%s\" for 'renderstylefloor'\n", str); continue; } case NAME_Renderstyleceiling: { const char *str = CheckString(key); if (!stricmp(str, "translucent")) sec->ChangeFlags(sector_t::ceiling, PLANEF_ADDITIVE, 0); else if (!stricmp(str, "add")) sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ADDITIVE); else sc.ScriptMessage("Unknown value \"%s\" for 'renderstyleceiling'\n", str); continue; } case NAME_Lightfloorabsolute: if (CheckBool(key)) sec->ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); else sec->ChangeFlags(sector_t::floor, PLANEF_ABSLIGHTING, 0); continue; case NAME_Lightceilingabsolute: if (CheckBool(key)) sec->ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); else sec->ChangeFlags(sector_t::ceiling, PLANEF_ABSLIGHTING, 0); continue; case NAME_Gravity: sec->gravity = CheckFloat(key); continue; case NAME_Lightcolor: lightcolor = CheckInt(key); continue; case NAME_Fadecolor: fadecolor = CheckInt(key); continue; case NAME_Desaturation: desaturation = int(255*CheckFloat(key)); continue; case NAME_Silent: Flag(sec->Flags, SECF_SILENT, key); continue; case NAME_NoRespawn: Flag(sec->Flags, SECF_NORESPAWN, key); continue; case NAME_Nofallingdamage: Flag(sec->Flags, SECF_NOFALLINGDAMAGE, key); continue; case NAME_Dropactors: Flag(sec->Flags, SECF_FLOORDROP, key); continue; case NAME_SoundSequence: sec->SeqName = CheckString(key); sec->seqType = -1; continue; case NAME_hidden: Flag(sec->MoreFlags, SECF_HIDDEN, key); break; case NAME_Waterzone: Flag(sec->MoreFlags, SECF_UNDERWATER, key); break; case NAME_floorplane_a: fplaneflags |= 1; fp[0] = CheckFloat(key); break; case NAME_floorplane_b: fplaneflags |= 2; fp[1] = CheckFloat(key); break; case NAME_floorplane_c: fplaneflags |= 4; fp[2] = CheckFloat(key); break; case NAME_floorplane_d: fplaneflags |= 8; fp[3] = CheckFloat(key); break; case NAME_ceilingplane_a: cplaneflags |= 1; cp[0] = CheckFloat(key); break; case NAME_ceilingplane_b: cplaneflags |= 2; cp[1] = CheckFloat(key); break; case NAME_ceilingplane_c: cplaneflags |= 4; cp[2] = CheckFloat(key); break; case NAME_ceilingplane_d: cplaneflags |= 8; cp[3] = CheckFloat(key); break; case NAME_damageamount: sec->damageamount = CheckInt(key); break; case NAME_damagetype: sec->damagetype = CheckString(key); break; case NAME_damageinterval: sec->damageinterval = CheckInt(key); if (sec->damageinterval < 1) sec->damageinterval = 1; break; case NAME_leakiness: sec->leakydamage = CheckInt(key); break; case NAME_damageterraineffect: Flag(sec->Flags, SECF_DMGTERRAINFX, key); break; case NAME_damagehazard: Flag(sec->Flags, SECF_HAZARD, key); break; case NAME_floorterrain: sec->terrainnum[sector_t::floor] = P_FindTerrain(CheckString(key)); break; case NAME_ceilingterrain: sec->terrainnum[sector_t::ceiling] = P_FindTerrain(CheckString(key)); break; case NAME_MoreIds: // delay parsing of the tag string until parsing of the sector is complete // This ensures that the ID is always the first tag in the list. tagstring = CheckString(key); break; default: break; } if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5)) { AddUserKey(key, UDMF_Sector, index); } } if (tagstring.IsNotEmpty()) { FScanner sc; sc.OpenString("tagstring", tagstring); // scan the string as long as valid numbers can be found while (sc.CheckNumber()) { if (sc.Number != 0) tagManager.AddSectorTag(index, sc.Number); } } if (sec->damageamount == 0) { // If no damage is set, clear all other related properties so that they do not interfere // with other means of setting them. sec->damagetype = NAME_None; sec->damageinterval = 0; sec->leakydamage = 0; sec->Flags &= ~SECF_DAMAGEFLAGS; } // Reset the planes to their defaults if not all of the plane equation's parameters were found. if (fplaneflags != 15) { sec->floorplane.SetAtHeight(sec->GetPlaneTexZ(sector_t::floor), sector_t::floor); } else { // normalize the vector, it must have a length of 1 DVector3 n = DVector3(fp[0], fp[1], fp[2]).Unit(); sec->floorplane.set(n.X, n.Y, n.Z, fp[3]); } if (cplaneflags != 15) { sec->ceilingplane.SetAtHeight(sec->GetPlaneTexZ(sector_t::ceiling), sector_t::ceiling); } else { DVector3 n = DVector3(cp[0], cp[1], cp[2]).Unit(); sec->ceilingplane.set(n.X, n.Y, n.Z, cp[3]); } if (lightcolor == -1 && fadecolor == -1 && desaturation == -1) { // [RH] Sectors default to white light with the default fade. // If they are outside (have a sky ceiling), they use the outside fog. if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special & 0xff) == Sector_Outside)) { if (fogMap == NULL) fogMap = GetSpecialLights(PalEntry(255, 255, 255), level.outsidefog, 0); sec->ColorMap = fogMap; } else { if (normMap == NULL) normMap = GetSpecialLights (PalEntry (255,255,255), level.fadeto, NormalLight.Desaturate); sec->ColorMap = normMap; } } else { if (lightcolor == -1) lightcolor = PalEntry(255,255,255); if (fadecolor == -1) { if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special & 0xff) == Sector_Outside)) fadecolor = level.outsidefog; else fadecolor = level.fadeto; } if (desaturation == -1) desaturation = NormalLight.Desaturate; sec->ColorMap = GetSpecialLights (lightcolor, fadecolor, desaturation); } }
/** Parse a token list. */ void Parse(const TokenNode *start, int depth) { TokenNode *tp; if(!start) { return; } if(JLIKELY(start->type == TOK_JWM)) { for(tp = start->subnodeHead; tp; tp = tp->next) { if(shouldReload) { switch(tp->type) { case TOK_ROOTMENU: ParseRootMenu(tp); break; case TOK_INCLUDE: ParseInclude(tp, depth); break; default: break; } } else { switch(tp->type) { case TOK_DESKTOPS: ParseDesktops(tp); break; case TOK_DOUBLECLICKSPEED: settings.doubleClickSpeed = ParseUnsigned(tp, tp->value); break; case TOK_DOUBLECLICKDELTA: settings.doubleClickDelta = ParseUnsigned(tp, tp->value); break; case TOK_FOCUSMODEL: ParseFocusModel(tp); break; case TOK_GROUP: ParseGroup(tp); break; case TOK_ICONPATH: AddIconPath(tp->value); break; case TOK_INCLUDE: ParseInclude(tp, depth); break; case TOK_KEY: ParseKey(tp); break; case TOK_MENUSTYLE: ParseMenuStyle(tp); break; case TOK_MOVEMODE: ParseMoveMode(tp); break; case TOK_PAGERSTYLE: ParsePagerStyle(tp); break; case TOK_POPUPSTYLE: ParsePopupStyle(tp); break; case TOK_RESIZEMODE: ParseResizeMode(tp); break; case TOK_RESTARTCOMMAND: AddRestartCommand(tp->value); break; case TOK_ROOTMENU: ParseRootMenu(tp); break; case TOK_SHUTDOWNCOMMAND: AddShutdownCommand(tp->value); break; case TOK_SNAPMODE: ParseSnapMode(tp); break; case TOK_STARTUPCOMMAND: AddStartupCommand(tp->value); break; case TOK_TASKLISTSTYLE: ParseTaskListStyle(tp); break; case TOK_TRAY: ParseTray(tp); break; case TOK_TRAYSTYLE: ParseTrayStyle(tp); break; case TOK_TRAYBUTTONSTYLE: ParseTrayButtonStyle(tp); break; case TOK_CLOCKSTYLE: ParseClockStyle(tp); break; case TOK_WINDOWSTYLE: ParseWindowStyle(tp); break; case TOK_BUTTONCLOSE: SetBorderIcon(BI_CLOSE, tp->value); break; case TOK_BUTTONMAX: SetBorderIcon(BI_MAX, tp->value); break; case TOK_BUTTONMAXACTIVE: SetBorderIcon(BI_MAX_ACTIVE, tp->value); break; case TOK_BUTTONMIN: SetBorderIcon(BI_MIN, tp->value); break; default: InvalidTag(tp, TOK_JWM); break; } } } } else { ParseError(start, "invalid start tag: %s", GetTokenName(start)); } }
GUIKeyboard::GUIKeyboard(xml_node<>* node) : GUIObject(node) { int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0; currentKey = NULL; highlightRenderCount = 0; hasHighlight = hasCapsHighlight = false; char resource[10], layout[8], row[5], key[6], longpress[7]; xml_attribute<>* attr; xml_node<>* child; xml_node<>* keylayout; xml_node<>* keyrow; for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++) { layouts[layoutindex].keyboardImg = NULL; memset(layouts[layoutindex].keys, 0, sizeof(Layout::keys)); memset(layouts[layoutindex].row_end_y, 0, sizeof(Layout::row_end_y)); } mRendered = false; currentLayout = 1; CapsLockOn = false; if (!node) return; mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlight); mCapsHighlightColor = LoadAttrColor(FindNode(node, "capshighlight"), "color", &hasCapsHighlight); child = FindNode(node, "keymargin"); mKeyMarginX = LoadAttrIntScaleX(child, "x", 0); mKeyMarginY = LoadAttrIntScaleY(child, "y", 0); child = FindNode(node, "background"); mBackgroundColor = LoadAttrColor(child, "color", COLOR(32,32,32,255)); child = FindNode(node, "key-alphanumeric"); mFont = PageManager::GetResources()->FindFont(LoadAttrString(child, "font", "keylabel")); mFontColor = LoadAttrColor(child, "textcolor", COLOR(255,255,255,255)); mKeyColorAlphanumeric = LoadAttrColor(child, "color", COLOR(0,0,0,0)); child = FindNode(node, "key-other"); mSmallFont = PageManager::GetResources()->FindFont(LoadAttrString(child, "font", "keylabel-small")); mFontColorSmall = LoadAttrColor(child, "textcolor", COLOR(192,192,192,255)); mKeyColorOther = LoadAttrColor(child, "color", COLOR(0,0,0,0)); child = FindNode(node, "longpress"); mLongpressFont = PageManager::GetResources()->FindFont(LoadAttrString(child, "font", "keylabel-longpress")); mLongpressFontColor = LoadAttrColor(child, "textcolor", COLOR(128,128,128,255)); LoadPlacement(child, &longpressOffsetX, &longpressOffsetY); LoadKeyLabels(node, 0); // load global key labels // compatibility ugliness: resources should be specified in the layouts themselves instead // Load the images for the different layouts child = FindNode(node, "layout"); if (child) { layoutindex = 1; strcpy(resource, "resource1"); attr = child->first_attribute(resource); while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) { layouts[layoutindex - 1].keyboardImg = LoadAttrImage(child, resource); layoutindex++; resource[8] = (char)(layoutindex + 48); attr = child->first_attribute(resource); } } // Check the first image to get height and width if (layouts[0].keyboardImg && layouts[0].keyboardImg->GetResource()) { mRenderW = layouts[0].keyboardImg->GetWidth(); mRenderH = layouts[0].keyboardImg->GetHeight(); } // Load all of the layout maps layoutindex = 1; strcpy(layout, "layout1"); keylayout = FindNode(node, layout); while (keylayout) { if (layoutindex > MAX_KEYBOARD_LAYOUTS) { LOGERR("Too many layouts defined in keyboard.\n"); return; } LoadKeyLabels(keylayout, layoutindex); // load per-layout key labels Layout& lay = layouts[layoutindex - 1]; child = keylayout->first_node("keysize"); keyHeight = LoadAttrIntScaleY(child, "height", 0); keyWidth = LoadAttrIntScaleX(child, "width", 0); // compatibility ugliness: capslock="0" means that this is the caps layout. Also it has nothing to do with keysize. lay.is_caps = (LoadAttrInt(child, "capslock", 1) == 0); // compatibility ugliness: revert_layout has nothing to do with keysize. lay.revert_layout = LoadAttrInt(child, "revert_layout", -1); rowindex = 1; Yindex = 0; strcpy(row, "row1"); keyrow = keylayout->first_node(row); while (keyrow) { if (rowindex > MAX_KEYBOARD_ROWS) { LOGERR("Too many rows defined in keyboard.\n"); return; } Yindex += keyHeight; lay.row_end_y[rowindex - 1] = Yindex; keyindex = 1; Xindex = 0; strcpy(key, "key01"); attr = keyrow->first_attribute(key); while (attr) { if (keyindex > MAX_KEYBOARD_KEYS) { LOGERR("Too many keys defined in a keyboard row.\n"); return; } const char* keyinfo = attr->value(); if (strlen(keyinfo) == 0) { LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex); return; } if (ParseKey(keyinfo, lay.keys[rowindex - 1][keyindex - 1], Xindex, keyWidth, false)) LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex); // PROCESS LONG PRESS INFO IF EXISTS sprintf(longpress, "long%02i", keyindex); attr = keyrow->first_attribute(longpress); if (attr) { const char* keyinfo = attr->value(); if (strlen(keyinfo) == 0) { LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex); return; } if (ParseKey(keyinfo, lay.keys[rowindex - 1][keyindex - 1], Xindex, keyWidth, true)) LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex); } keyindex++; sprintf(key, "key%02i", keyindex); attr = keyrow->first_attribute(key); } rowindex++; row[3] = (char)(rowindex + 48); keyrow = keylayout->first_node(row); } layoutindex++; layout[6] = (char)(layoutindex + 48); keylayout = FindNode(node, layout); } int x, y; // Load the placement LoadPlacement(FindNode(node, "placement"), &x, &y, &mRenderW, &mRenderH); SetRenderPos(x, y, mRenderW, mRenderH); return; }
nsresult CacheFileMetadata::ParseMetadata(uint32_t aMetaOffset, uint32_t aBufOffset, bool aHaveKey) { LOG(("CacheFileMetadata::ParseMetadata() [this=%p, metaOffset=%d, " "bufOffset=%d, haveKey=%u]", this, aMetaOffset, aBufOffset, aHaveKey)); nsresult rv; uint32_t metaposOffset = mBufSize - sizeof(uint32_t); uint32_t hashesOffset = aBufOffset + sizeof(uint32_t); uint32_t hashCount = aMetaOffset / kChunkSize; if (aMetaOffset % kChunkSize) hashCount++; uint32_t hashesLen = hashCount * sizeof(CacheHash::Hash16_t); uint32_t hdrOffset = hashesOffset + hashesLen; uint32_t keyOffset = hdrOffset + sizeof(CacheFileMetadataHeader); LOG(("CacheFileMetadata::ParseMetadata() [this=%p]\n metaposOffset=%d\n " "hashesOffset=%d\n hashCount=%d\n hashesLen=%d\n hdfOffset=%d\n " "keyOffset=%d\n", this, metaposOffset, hashesOffset, hashCount, hashesLen,hdrOffset, keyOffset)); if (keyOffset > metaposOffset) { LOG(("CacheFileMetadata::ParseMetadata() - Wrong keyOffset! [this=%p]", this)); return NS_ERROR_FILE_CORRUPTED; } mMetaHdr.ReadFromBuf(mBuf + hdrOffset); if (mMetaHdr.mVersion != kCacheEntryVersion) { LOG(("CacheFileMetadata::ParseMetadata() - Not a version we understand to. " "[version=0x%x, this=%p]", mMetaHdr.mVersion, this)); return NS_ERROR_UNEXPECTED; } uint32_t elementsOffset = mMetaHdr.mKeySize + keyOffset + 1; if (elementsOffset > metaposOffset) { LOG(("CacheFileMetadata::ParseMetadata() - Wrong elementsOffset %d " "[this=%p]", elementsOffset, this)); return NS_ERROR_FILE_CORRUPTED; } // check that key ends with \0 if (mBuf[elementsOffset - 1] != 0) { LOG(("CacheFileMetadata::ParseMetadata() - Elements not null terminated. " "[this=%p]", this)); return NS_ERROR_FILE_CORRUPTED; } if (!aHaveKey) { // get the key form metadata mKey.Assign(mBuf + keyOffset, mMetaHdr.mKeySize); rv = ParseKey(mKey); if (NS_FAILED(rv)) return rv; } else { if (mMetaHdr.mKeySize != mKey.Length()) { LOG(("CacheFileMetadata::ParseMetadata() - Key collision (1), key=%s " "[this=%p]", nsCString(mBuf + keyOffset, mMetaHdr.mKeySize).get(), this)); return NS_ERROR_FILE_CORRUPTED; } if (memcmp(mKey.get(), mBuf + keyOffset, mKey.Length()) != 0) { LOG(("CacheFileMetadata::ParseMetadata() - Key collision (2), key=%s " "[this=%p]", nsCString(mBuf + keyOffset, mMetaHdr.mKeySize).get(), this)); return NS_ERROR_FILE_CORRUPTED; } } // check metadata hash (data from hashesOffset to metaposOffset) CacheHash::Hash32_t hashComputed, hashExpected; hashComputed = CacheHash::Hash(mBuf + hashesOffset, metaposOffset - hashesOffset); hashExpected = NetworkEndian::readUint32(mBuf + aBufOffset); if (hashComputed != hashExpected) { LOG(("CacheFileMetadata::ParseMetadata() - Metadata hash mismatch! Hash of " "the metadata is %x, hash in file is %x [this=%p]", hashComputed, hashExpected, this)); return NS_ERROR_FILE_CORRUPTED; } // check elements rv = CheckElements(mBuf + elementsOffset, metaposOffset - elementsOffset); if (NS_FAILED(rv)) return rv; mHashArraySize = hashesLen; mHashCount = hashCount; if (mHashArraySize) { mHashArray = static_cast<CacheHash::Hash16_t *>( moz_xmalloc(mHashArraySize)); memcpy(mHashArray, mBuf + hashesOffset, mHashArraySize); } mMetaHdr.mFetchCount++; MarkDirty(); mElementsSize = metaposOffset - elementsOffset; memmove(mBuf, mBuf + elementsOffset, mElementsSize); mOffset = aMetaOffset; // TODO: shrink memory if buffer is too big DoMemoryReport(MemoryUsage()); return NS_OK; }
void ParseSidedef(side_t *sd, intmapsidedef_t *sdt, int index) { fixed_t texofs[2]={0,0}; memset(sd, 0, sizeof(*sd)); sdt->bottomtexture = "-"; sdt->toptexture = "-"; sdt->midtexture = "-"; sd->SetTextureXScale(FRACUNIT); sd->SetTextureYScale(FRACUNIT); sc.MustGetToken('{'); while (!sc.CheckToken('}')) { FName key = ParseKey(); switch(key) { case NAME_Offsetx: texofs[0] = CheckInt(key) << FRACBITS; continue; case NAME_Offsety: texofs[1] = CheckInt(key) << FRACBITS; continue; case NAME_Texturetop: sdt->toptexture = CheckString(key); continue; case NAME_Texturebottom: sdt->bottomtexture = CheckString(key); continue; case NAME_Texturemiddle: sdt->midtexture = CheckString(key); continue; case NAME_Sector: sd->sector = (sector_t*)(intptr_t)CheckInt(key); continue; default: break; } if (namespace_bits & (Zd|Zdt|Va)) switch(key) { case NAME_offsetx_top: sd->SetTextureXOffset(side_t::top, CheckFixed(key)); continue; case NAME_offsety_top: sd->SetTextureYOffset(side_t::top, CheckFixed(key)); continue; case NAME_offsetx_mid: sd->SetTextureXOffset(side_t::mid, CheckFixed(key)); continue; case NAME_offsety_mid: sd->SetTextureYOffset(side_t::mid, CheckFixed(key)); continue; case NAME_offsetx_bottom: sd->SetTextureXOffset(side_t::bottom, CheckFixed(key)); continue; case NAME_offsety_bottom: sd->SetTextureYOffset(side_t::bottom, CheckFixed(key)); continue; case NAME_scalex_top: sd->SetTextureXScale(side_t::top, CheckFixed(key)); continue; case NAME_scaley_top: sd->SetTextureYScale(side_t::top, CheckFixed(key)); continue; case NAME_scalex_mid: sd->SetTextureXScale(side_t::mid, CheckFixed(key)); continue; case NAME_scaley_mid: sd->SetTextureYScale(side_t::mid, CheckFixed(key)); continue; case NAME_scalex_bottom: sd->SetTextureXScale(side_t::bottom, CheckFixed(key)); continue; case NAME_scaley_bottom: sd->SetTextureYScale(side_t::bottom, CheckFixed(key)); continue; case NAME_light: sd->SetLight(CheckInt(key)); continue; case NAME_lightabsolute: Flag(sd->Flags, WALLF_ABSLIGHTING, key); continue; case NAME_lightfog: Flag(sd->Flags, WALLF_LIGHT_FOG, key); continue; case NAME_nofakecontrast: Flag(sd->Flags, WALLF_NOFAKECONTRAST, key); continue; case NAME_smoothlighting: Flag(sd->Flags, WALLF_SMOOTHLIGHTING, key); continue; case NAME_Wrapmidtex: Flag(sd->Flags, WALLF_WRAP_MIDTEX, key); continue; case NAME_Clipmidtex: Flag(sd->Flags, WALLF_CLIP_MIDTEX, key); continue; case NAME_Nodecals: Flag(sd->Flags, WALLF_NOAUTODECALS, key); continue; default: break; } if (!strnicmp("user_", key.GetChars(), 5)) { AddUserKey(key, UDMF_Side, index); } } // initialization of these is delayed to allow separate offsets and add them with the global ones. sd->AddTextureXOffset(side_t::top, texofs[0]); sd->AddTextureXOffset(side_t::mid, texofs[0]); sd->AddTextureXOffset(side_t::bottom, texofs[0]); sd->AddTextureYOffset(side_t::top, texofs[1]); sd->AddTextureYOffset(side_t::mid, texofs[1]); sd->AddTextureYOffset(side_t::bottom, texofs[1]); }
bool MantaSettingsParser::UpdateSetting(const string& key, const string& val) { bool bRet = false; bool debug = m_pSettings->GetDebugMode(); int iVal = atoi(val.c_str()); if (IsValidKey(key)) { string type, function; unsigned long index; ParseKey(key, type, function, index); if (type == "Pad") { if (function == "Mode") m_pSettings->SetPad_Mode((PadValMode)iVal); else if (function == "LayoutTitle") m_pSettings->SetPadLayoutTitle(val.c_str()); else if (function == "MonoCC") m_pSettings->SetPad_MonoCCNumber(iVal); else if (function == "InactiveColor") { m_pSettings->SetAllPadInactiveColor((Manta::LEDState)iVal); if (debug) cout << " Pad Inactive Color: " << iVal << endl; } else if (function == "OnColor") { m_pSettings->SetAllPadOnColor((Manta::LEDState)iVal); if (debug) cout << " Pad On Color: " << iVal << endl; } else if (function == "OffColor") { m_pSettings->SetAllPadOffColor((Manta::LEDState)iVal); if (debug) cout << " Pad Off Color: " << iVal << endl; } else if (function == "Channel") m_pSettings->SetPad_Channel(iVal); else { int midi = -1; int chan = 1; ParseMidiValue(val, midi, chan); if (debug) cout << " Pad " << index << " Midi: " << midi << " " << chan << endl; m_pSettings->SetPad(index - 1, chan - 1, midi - 1); } } else if (type == "Button") { if (function == "MIDI") { int midi = -1; int chan = 1; ParseMidiValue(val, midi, chan); if (index == 1 || index == string::npos) { m_pSettings->SetButton_Midi(0, midi); m_pSettings->SetButton_Channel(0, chan); } else if (index == 2 || index == string::npos) { m_pSettings->SetButton_Midi(1, midi); m_pSettings->SetButton_Channel(0, chan); } else if (index == 3 || index == string::npos) { m_pSettings->SetButton_Midi(2, midi); m_pSettings->SetButton_Channel(0, chan); } else if (index == 4 || index == string::npos) { m_pSettings->SetButton_Midi(3, midi); m_pSettings->SetButton_Channel(0, chan); } } else if (function == "Mode") { if (index == 1 || index == string::npos) m_pSettings->SetButton_Mode(0, (ButtonMode)iVal); else if (index == 2 || index == string::npos) m_pSettings->SetButton_Mode(1, (ButtonMode)iVal); else if (index == 3 || index == string::npos) m_pSettings->SetButton_Mode(2, (ButtonMode)iVal); else if (index == 4 || index == string::npos) m_pSettings->SetButton_Mode(3, (ButtonMode)iVal); } else if (function == "InactiveColor") { if (index == 1 || index == string::npos) m_pSettings->SetButton_InactiveColor(0, (Manta::LEDState)iVal); else if (index == 2 || index == string::npos) m_pSettings->SetButton_InactiveColor(1, (Manta::LEDState)iVal); else if (index == 3 || index == string::npos) m_pSettings->SetButton_InactiveColor(2, (Manta::LEDState)iVal); else if (index == 4 || index == string::npos) m_pSettings->SetButton_InactiveColor(3, (Manta::LEDState)iVal); } else if (function == "OnColor") { if (index == 1 || index == string::npos) m_pSettings->SetButton_OnColor(0, (Manta::LEDState)iVal); else if (index == 2 || index == string::npos) m_pSettings->SetButton_OnColor(1, (Manta::LEDState)iVal); else if (index == 3 || index == string::npos) m_pSettings->SetButton_OnColor(2, (Manta::LEDState)iVal); else if (index == 4 || index == string::npos) m_pSettings->SetButton_OnColor(3, (Manta::LEDState)iVal); } else if (function == "OffColor") { if (index == 1 || index == string::npos) m_pSettings->SetButton_OffColor(0, (Manta::LEDState)iVal); else if (index == 2 || index == string::npos) m_pSettings->SetButton_OffColor(1, (Manta::LEDState)iVal); else if (index == 3 || index == string::npos) m_pSettings->SetButton_OffColor(2, (Manta::LEDState)iVal); else if (index == 4 || index == string::npos) m_pSettings->SetButton_OffColor(3, (Manta::LEDState)iVal); } } else if (type == "Slider") { if (function == "MIDI") { int midi = -1; int chan = 1; ParseMidiValue(val, midi, chan); if (index == 0 || index == string::npos) { m_pSettings->SetSlider_Midi(0, midi); m_pSettings->SetSlider_Channel(0, chan); } else if (index == 1 || index == string::npos) { m_pSettings->SetSlider_Midi(1, midi); m_pSettings->SetSlider_Channel(1, chan); } } else if (function == "Mode") { if (index == 0 || index == string::npos) m_pSettings->SetSlider_Mode(0, (SliderMode)iVal); else if (index == 1 || index == string::npos) m_pSettings->SetSlider_Mode(1, (SliderMode)iVal); } } else { if (key == "Velocity") m_pSettings->SetUseVelocity(iVal); } } return bRet; }