diff --git a/RetroEDv2/main.cpp b/RetroEDv2/main.cpp index eaabff1..5de3c7f 100644 --- a/RetroEDv2/main.cpp +++ b/RetroEDv2/main.cpp @@ -212,6 +212,17 @@ int main(int argc, char *argv[]) writer.flush(); } + // copy RSDKv5 backup var list if it doesn't exist + if (!QFile(homeDir + "RSDKv5VarNames.txt").exists()) { + Reader reader(":/resources/RSDKv5VarNames.txt"); + QByteArray bytes = reader.readByteArray(reader.filesize); + reader.close(); + + Writer writer(homeDir + "RSDKv5VarNames.txt"); + writer.write(bytes); + writer.flush(); + } + PrintLog("===================================================="); PrintLog("New RetroED instance: " + QDateTime::currentDateTime().toString()); PrintLog(QString("Version: ") + RE_VERSION); diff --git a/RetroEDv2/resources.qrc b/RetroEDv2/resources.qrc index a6d3a69..ff57760 100644 --- a/RetroEDv2/resources.qrc +++ b/RetroEDv2/resources.qrc @@ -60,5 +60,6 @@ resources/splash.png resources/splash.svg icons/ic_stamp_selection_48px.svg + resources/RSDKv5VarNames.txt diff --git a/RetroEDv2/resources/RSDKv5VarNames.txt b/RetroEDv2/resources/RSDKv5VarNames.txt new file mode 100644 index 0000000..d4c2e18 --- /dev/null +++ b/RetroEDv2/resources/RSDKv5VarNames.txt @@ -0,0 +1,768 @@ +type +direction +size +interval +speed +angle +length +amplitude +intervalOffset +planeFilter +height +childCount +tag +buttonTag +orientation +duration +frameID +disabled +offset +aniID +distance +delay +dir +onlyMighty +timer +id +startDir +radius +force +rotSpeed +priority +mode +onGround +listID +align +parameter +subtype +detectSize +triggerID +flags +hitCount +frame +characterID +drawGroup +useStageConfig +skyAlpha +waterOnly +oscillate +shieldRange +triggerDir +triggerMode +groundVel +nummoves +parallaxFactor +hiddenAtStart +nodeFlag +power +bumpable +go +shift +playerID +vsBoundsOffset +vsExtendBottom +forceFall +targetLayer.id +hasTension +range +twirl +width +respawn +smashSides +onlyKnux +limit +forKnux +exit +numJumps +bombTime +bezCtrlAngle +bezCtrlLength +forceEnd +ignoreCliffs +shotRange +shootOffset +shootSize +master +charge +targetLayer +shape +isPlayer2 +node +flipCount +period +ignoreItemBox +drawOverTV +layerSrc +layerDest +pathMovement +pathSize +spinDirection +innerRadius +speedIn +wait +speedOut +oneWay +overHUD +fadeOutBlack +outerRadius +fadeWhite +fadeBlack +waitForTrigger +minY +maxY +boatID +paraOffset +paraYFactor +paraPreview +subOff1 +subOff2 +depth +affectPlayer +quality +distX1 +distX2 +preset +offset1 +offset2 +offset3 +triggerSize +subType +subFlip +bottomSmash +knuxSmash +dip +lrzConvPhys +flip +sawDelay +sawSpeed +hasSaw +setID +hVel +hDist +bobDist +rotOffset +rotDir +manual +strict +text0 +text3 +text4 +text5 +text6 +text7 +seq0 +seq1 +controller +letterID +enabled +lottoNum +hitboxSize +flipVal +seqCount +seqLoop +calibration +debugParticles +startAngleA +startAngleB +endAngleA +endAngleB +durationA +durationB +holdDuration +motionType +trackFile +soundTestTitle +trackID +trackLoop +playOnLoad +always +noDeathSwap +paletteFile +rowFlags +bankID +loadOnce +minCraneID +retractable +craneID +leafPattern +tileLayer +pileSize +maxSpeed +emitterMode +sfx +spinSpeed +angleM +gap +numChildren +offTop +offBottom +letter +open +automatic +decorMode +counter +noMove +fluctuation +running +lockCamera +pivotRadius +spikeRadius +spikeCount +oscOff +side +sprayTime +shatter +silhouette +timerMode +timerGroup +snaps +timeAttackFreeze +extend +fireOrbs +len +offL +offR +printDir +srcC +srcM +srcY +start +yDir +printRows +spearDir +prize +origin +colWidth +rowHeight +yOffset +autoGrip +bias +boostPower +boostAlways +forwardOnly +allowTubeInput +bounceCount +numActive +minDelay +drawFlag +flashSpeed +reversible +finishLine +extendTop +extendBottom +boundsSize +boundsOffset +topBoundary +bossID +zoneName +warpTag +iD +cableID +targetSpeed +easeToSpeed +fastMode +forceSpeed +links +stepCount +initialSide +stationary +leftFanDir +leftFanDuration +leftFanStrength +leftFanLength +rightFanDir +rightFanDuration +rightFanStrength +rightFanLength +angleVel +throttle +startNode +machQuota1 +machQuota2 +machQuota3 +startingRings +behavior +matAngle +rampCount +choiceCount +choiceDir +assignsP1 +freeBindP2 +transition +promptID +headingAnchor +clipSize +clipOffset +noText +auxIcon +auxListID +auxFrameID +parentTag +activeOnLoad +noWidgets +resetSelection +rowCount +columnCount +startingID +cameraOffset +noClamp +noWrap +isHeading +hasShape +dioramaID +headingID +inputID +buttonID +stopMusic +panelSize +topListID +topFrameID +botListID +botFrameID +botAlignRight +botHidden +showsName +encoreMode +debugEncoreDraw +dCharPoint +dCharPartner +dCharStock1 +dCharStock2 +dCharStock3 +text1 +text2 +videoFile1 +videoFile2 +audioFile +gotoStage +stageListCategory +stageListName +numRows +trophyCount +row0Label +row1Label +row2Label +row3Label +row4Label +row5Label +row6Label +row7Label +row8Label +row9Label +row10Label +row11Label +row12Label +row0Highlight +row1Highlight +row2Highlight +row3Highlight +row4Highlight +row5Highlight +row6Highlight +row7Highlight +row8Highlight +row9Highlight +row10Highlight +row11Highlight +row12Highlight +val +maxVal +p1Score +p2Score +showWinner +winnerID +act +xOut +obfuscate +arrowWidth +steps +destinationTag +definesBounds +xBoundaryPosL +xBoundaryPosR +yBoundaryPosT +yBoundaryPosB +effect +warpToCenter +forcePlayerState +angVel +yVel +distUp +distDown +YVelocity +waitingPeriod +reverse +destructible +color +bubbles +pathID +spikeRange +startType +playerType +invisible +missileCount +missileDelay +playerAni +fanEnabled +offRange +chainCount +angleStart +angleEnd +autoOpen +close +mirror +angleSpd +angleDir +endLen +dripRate +passThresh +detectOffset +hover +releaseType +hitThresh +startOff +maxDist +spread +activationRange +despawn +destructable +drawLow +thresh1 +thresh2 +thresh3 +thresh4 +soundOffset +upwardAmount +drawGroupID +unbreakable +debrisDrawGroup +sequenceID +health +distOffset +chainLength +phase512 +vertical +flipPost +pullDir +itemOffset +tileID +animate +disable +controlFlag +soundName +loopPos +src1 +dst1 +src2 +dst2 +copyOrigin +copyRange +updateRange +activationTime +activationCount +activationAddOffset +bgID +repeat +topOffset +unbreakableThrowingHammer +burnable +slant +walkOnto +silent +openType +targetOffset +precision +nudge +retriggerable +eventOnly +mightyOnly +slope +globalControl +buttonBehavior +off +strength +fbzAchievement +strengthEX +rangeType +startRot +repeatTimes +repeatSpacing +additive +reverseX +reverseY +knuxDelete +waterVis +activation +deactivation +rotation +activationLimit +allPlayers +collision +tileOrigin +chainDir +nodeCount +setActive +resetOffscreen +manualTrigger +buffer +spdLimit +targetPos +dirMask +numDuds +r +g +b +destroyOnTrigger +surfaceWaves +behaviour +alignFrom +restoreSpd +restoreAccel +lockLeft +lockRight +vsDisable +deactivated +onExit +dontSetBounds +soundID +noCrush +noPush +activeNormal +timeAttackOnly +noChibi +hurtType +ignoreTop +ignoreBottom +ignoreLeft +ignoreRight +isFalling +hidden +onPath +moveType +vsBoundsSize +vsExtendTop +super +moving +stagger +flipFlag +swap +passThrough +velOverride +vsRemove +strName +actID +noBanner +zonePalette +zoneID +text +selectable +data0 +data1 +data2 +data3 +highlighted +specialDisable +targetOff +waitTime +uniAniID +orbAniID +orbCount +orbit.radius +orbit.speed +orbit.angle +throwRangeAndSpeed +moveSpeed +orderOrbs +dropOrbs +modifier +detectRange +blowTime +blowWait +segmentCount +drawType +response +breakType +retract +knuxOnly +enableIfKnux +startFrame +linkCount +linkOff +spoutID +isClosed +startAngle +moveCount +fling +suckAtBase +lockPlayer +crumbling +chainCnt +breakClimb +detectDirection +attribute +scrollSpeed +loopPoint +overrideDrawGroup +destDist +revealFlag +darkSky +travelSpeed +setOpen +isSolid +activated +forceOffset +offLeft +offRight +spawnType +activationSize +groupID +playSound +ropeSize +angleOffset +fallSpeed +gravity +fromSpawner +frequency +frequencyOffset +outTime +catchFire +hiding +hasCap +rangeVal +patrolTime +accel +speedCap +dist +extent +hasWeight +noSwing +testMode +speedPull +speedMove +root[0] +extent[0] +root[1] +extent[1] +root[2] +extent[2] +teeth[0] +teeth[1] +teeth[2] +zdepth +aniTileCF +dg +ignore +falls +count +bounceDampingVelY +spinning +hopCount +platFlag +wrapHandling +dest +nodeCnt +switchID +eventTrigger +sandLength +activeRange +emeraldID +visible +glow.sourceBank +glow.sourceIndex +glow.targetIndex[0] +glow.targetIndex[1] +glow.targetIndex[2] +frontSize +propCount +propSpacing +playerTarget +parameter1 +parameter2 +pilot +globeAlpha +playfieldA +playfieldB +bgColor1 +bgColor2 +bgColor3 +paletteID +sub +slotID +screenCoords +smashTop +pushable +spacing +scratch +startDrawGroup +startSlot +deactivate +rangeOffset +rangeSize +groundOffset +ignoreGround +ignoreShield +delayTime +bomb_0_00 +bomb_0_01 +bomb_0_02 +bomb_0_03 +bomb_0_04 +bomb_0_05 +bomb_0_06 +bomb_0_07 +bomb_0_08 +bomb_0_09 +bomb_0_10 +bomb_0_11 +bomb_0_12 +bomb_0_13 +bomb_0_14 +bomb_0_15 +bomb_0_16 +bomb_0_17 +bomb_0_18 +bomb_0_19 +bomb_0_20 +bomb_1_00 +bomb_1_01 +bomb_1_02 +bomb_1_03 +bomb_1_04 +bomb_1_05 +bomb_1_06 +bomb_1_07 +bomb_1_08 +bomb_1_09 +bomb_1_10 +bomb_1_11 +bomb_1_12 +bomb_1_13 +bomb_1_14 +bomb_1_15 +bomb_1_16 +bomb_1_17 +bomb_1_18 +bomb_1_19 +bomb_1_20 +bomb_2_00 +bomb_2_01 +bomb_2_02 +bomb_2_03 +bomb_2_04 +bomb_2_05 +bomb_2_06 +bomb_2_07 +bomb_2_08 +bomb_2_09 +bomb_2_10 +bomb_2_11 +bomb_2_12 +bomb_2_13 +bomb_2_14 +bomb_2_15 +bomb_2_16 +bomb_2_17 +bomb_2_18 +bomb_2_19 +bomb_2_20 +coffiSpeed diff --git a/RetroEDv2/tools/compiler/compilerv2.cpp b/RetroEDv2/tools/compiler/compilerv2.cpp index a0af259..4eb8173 100644 --- a/RetroEDv2/tools/compiler/compilerv2.cpp +++ b/RetroEDv2/tools/compiler/compilerv2.cpp @@ -1109,6 +1109,7 @@ void Compilerv2::ParseScriptFile(QString scriptName, int scriptID) } scriptError = false; + fileFound = true; Reader reader(scriptName); if (reader.initialised) { @@ -1266,6 +1267,8 @@ void Compilerv2::ParseScriptFile(QString scriptName, int scriptID) } reader.close(); + } else { + fileFound = false; } } diff --git a/RetroEDv2/tools/compiler/compilerv2.hpp b/RetroEDv2/tools/compiler/compilerv2.hpp index 37f028d..45056d2 100644 --- a/RetroEDv2/tools/compiler/compilerv2.hpp +++ b/RetroEDv2/tools/compiler/compilerv2.hpp @@ -98,6 +98,7 @@ class Compilerv2 int globalScriptCodeCount = 0; int globalJumpTableCount = 0; + bool fileFound = false; bool scriptError = false; QString errorMsg = ""; QString errorPos = ""; diff --git a/RetroEDv2/tools/compiler/compilerv3.cpp b/RetroEDv2/tools/compiler/compilerv3.cpp index 8f3c696..00ab2b7 100644 --- a/RetroEDv2/tools/compiler/compilerv3.cpp +++ b/RetroEDv2/tools/compiler/compilerv3.cpp @@ -1457,6 +1457,7 @@ void Compilerv3::ParseScriptFile(QString scriptName, int scriptID, bool inEditor } scriptError = false; + fileFound = true; Reader reader(scriptName); if (reader.initialised) { @@ -1736,6 +1737,8 @@ void Compilerv3::ParseScriptFile(QString scriptName, int scriptID, bool inEditor } reader.close(); + } else { + fileFound = false; } } diff --git a/RetroEDv2/tools/compiler/compilerv3.hpp b/RetroEDv2/tools/compiler/compilerv3.hpp index b56c6d8..e8c9af0 100644 --- a/RetroEDv2/tools/compiler/compilerv3.hpp +++ b/RetroEDv2/tools/compiler/compilerv3.hpp @@ -172,6 +172,7 @@ class Compilerv3 int globalJumpTableCount = 0; bool scriptError = false; + bool fileFound = false; QString errorMsg = ""; QString errorPos = ""; QString errorScr = ""; diff --git a/RetroEDv2/tools/compiler/compilerv4.cpp b/RetroEDv2/tools/compiler/compilerv4.cpp index 5bfb5c1..55bdd20 100644 --- a/RetroEDv2/tools/compiler/compilerv4.cpp +++ b/RetroEDv2/tools/compiler/compilerv4.cpp @@ -3672,6 +3672,7 @@ void Compilerv4::ParseScriptFile(QString scriptName, int scriptID, bool inEditor } scriptError = false; + fileFound = true; Reader reader(scriptName); if (reader.initialised) { @@ -4014,6 +4015,8 @@ void Compilerv4::ParseScriptFile(QString scriptName, int scriptID, bool inEditor } reader.close(); + } else { + fileFound = false; } } diff --git a/RetroEDv2/tools/compiler/compilerv4.hpp b/RetroEDv2/tools/compiler/compilerv4.hpp index 951e2a6..61d8e68 100644 --- a/RetroEDv2/tools/compiler/compilerv4.hpp +++ b/RetroEDv2/tools/compiler/compilerv4.hpp @@ -235,6 +235,7 @@ class Compilerv4 int globalScriptCodeCount = 0; int globalJumpTableCount = 0; + bool fileFound = false; bool scriptError = false; QString errorMsg = ""; QString errorPos = ""; diff --git a/RetroEDv2/tools/gamelink/gamelink.cpp b/RetroEDv2/tools/gamelink/gamelink.cpp index 5372db3..69a041b 100644 --- a/RetroEDv2/tools/gamelink/gamelink.cpp +++ b/RetroEDv2/tools/gamelink/gamelink.cpp @@ -249,18 +249,27 @@ void GameLink::LinkGameObjects(QString gameName) logicLib->setFileName(gameName); logicLib->load(); - if (!logicLib->isLoaded()) + if (!logicLib->isLoaded()){ PrintLog("Failed to link: " + logicLib->errorString()); - + if (logicLib->errorString().contains("0x000000c1")) + error = 1; + } + // 0x000000c1 = wrong architecture void (*linkGameLogic)(void *) = NULL; - revision = 3; if (logicLib->isLoaded()) { linkGameLogic = (void (*)(void *))logicLib->resolve("LinkGameLogicDLL"); int *RSDKRevision = (int *)logicLib->resolve("RSDKRevision"); - if (RSDKRevision) - revision = *RSDKRevision; + if (RSDKRevision){ + if (*RSDKRevision == -1){ + linkGameLogic = NULL; + error = 2; + PrintLog("Failed to link: Not a valid Game library"); + } else { + revision = *RSDKRevision; + } + } } if (linkGameLogic) { @@ -339,11 +348,11 @@ void GameLink::LinkGameObjects(QString gameName) if (globalVarsInitCB) globalVarsInitCB(globalVariablesPtr); - printf("sucessfully linked game logic!\n"); - printf("linked %d objects!\n", gameObjectList.count()); + PrintLog("sucessfully linked game logic!"); + PrintLog(QString("linked %1 objects!").arg(gameObjectList.count())); } else { - printf("failed to link game logic...\n"); + PrintLog("failed to link game logic..."); } for (int i = 0; i < gameObjectList.count(); ++i) { diff --git a/RetroEDv2/tools/gamelink/gamelink.hpp b/RetroEDv2/tools/gamelink/gamelink.hpp index b3de51f..7cd2502 100644 --- a/RetroEDv2/tools/gamelink/gamelink.hpp +++ b/RetroEDv2/tools/gamelink/gamelink.hpp @@ -460,7 +460,8 @@ class GameLink void LinkGameObjects(QString gameName = "Game"); void unload(); - int revision = 3; + int revision = 3; + int error = 0; byte *globalVariablesPtr = nullptr; void (*globalVarsInitCB)(void *globals) = nullptr; diff --git a/RetroEDv2/tools/gamelink/gameobjects.cpp b/RetroEDv2/tools/gamelink/gameobjects.cpp index 274d2a5..931d414 100644 --- a/RetroEDv2/tools/gamelink/gameobjects.cpp +++ b/RetroEDv2/tools/gamelink/gameobjects.cpp @@ -7,8 +7,8 @@ void FunctionTable::RegisterObjectv5(GameObject **sVars, const char *name, uint uint staticClassSize, void (*update)(void), void (*lateUpdate)(void), void (*staticUpdate)(void), void (*draw)(void), void (*create)(void *), - void (*stageLoad)(void), void (*editorLoad)(void), - void (*editorDraw)(void), void (*serialize)(void)) + void (*stageLoad)(void), void (*editorDraw)(void), + void (*editorLoad)(void), void (*serialize)(void)) { RegisterObjectv5U(sVars, name, entityClassSize, staticClassSize, update, lateUpdate, staticUpdate, draw, create, stageLoad, editorLoad, editorDraw, serialize, NULL); diff --git a/RetroEDv2/tools/gamelink/gameobjects.hpp b/RetroEDv2/tools/gamelink/gameobjects.hpp index 5ba9a3f..d2406ef 100644 --- a/RetroEDv2/tools/gamelink/gameobjects.hpp +++ b/RetroEDv2/tools/gamelink/gameobjects.hpp @@ -37,7 +37,7 @@ namespace FunctionTable void RegisterObjectv5(GameObject **sVars, const char *name, uint entityClassSize, uint staticClassSize, void (*update)(void), void (*lateUpdate)(void), void (*staticUpdate)(void), void (*draw)(void), void (*create)(void *), void (*stageLoad)(void), - void (*editorLoad)(void), void (*editorDraw)(void), void (*serialize)(void)); + void (*editorDraw)(void), void (*editorLoad)(void), void (*serialize)(void)); void RegisterObjectv5U(GameObject **sVars, const char *name, uint entityClassSize, uint staticClassSize, void (*update)(void), void (*lateUpdate)(void), void (*staticUpdate)(void), void (*draw)(void), void (*create)(void *), void (*stageLoad)(void), diff --git a/RetroEDv2/tools/sceneeditor.cpp b/RetroEDv2/tools/sceneeditor.cpp index af7a789..270bca8 100644 --- a/RetroEDv2/tools/sceneeditor.cpp +++ b/RetroEDv2/tools/sceneeditor.cpp @@ -2730,7 +2730,6 @@ void SceneEditor::LoadScene(QString scnPath, QString gcfPath, byte gameType) basePath + "ZoneBG.map"); QString pathTIL = WorkingDirManager::GetPath("Stages/" + viewer->currentFolder + "/Zone.til", basePath + "Zone.til"); - RSDKv1::TileConfig tileconfig; background.read(gameType, pathBG); @@ -3461,6 +3460,9 @@ void SceneEditor::InitGameLink() } scriptError = false; + viewer->linkError = -1; + int unknownScriptCount = 0; + switch (viewer->gameType) { case ENGINE_v1: break; // read the editor stuff from this somehow (idk how to parse it lol) case ENGINE_v2: { // parse the RSDK sub and use that data to know what to draw @@ -3475,6 +3477,9 @@ void SceneEditor::InitGameLink() compilerv2->ParseScriptFile(scriptPath, scrID++); + if (!compilerv2->fileFound) + unknownScriptCount++; + if (compilerv2->scriptError) { PrintLog(compilerv2->errorMsg); PrintLog(compilerv2->errorPos); @@ -3489,6 +3494,7 @@ void SceneEditor::InitGameLink() compilerv2->objectScriptList[scrID - 1].subRSDK.scriptCodePtr = -1; compilerv2->objectScriptList[scrID - 1].subRSDK.jumpTablePtr = -1; scriptError = true; + viewer->linkError = 1; } } } @@ -3499,6 +3505,9 @@ void SceneEditor::InitGameLink() WorkingDirManager::GetPath("/Scripts/" + stageConfig.objects[i].script, scriptPath); compilerv2->ParseScriptFile(scriptPath, scrID++); + if (!compilerv2->fileFound) + unknownScriptCount++; + if (compilerv2->scriptError) { PrintLog(compilerv2->errorMsg); PrintLog(compilerv2->errorPos); @@ -3513,8 +3522,20 @@ void SceneEditor::InitGameLink() compilerv2->objectScriptList[scrID - 1].subRSDK.scriptCodePtr = -1; compilerv2->objectScriptList[scrID - 1].subRSDK.jumpTablePtr = -1; scriptError = true; + viewer->linkError = 1; } } + if (stageConfig.loadGlobalScripts){ + if (unknownScriptCount != 0) + viewer->linkError = 2; + if (unknownScriptCount == gameConfig.objects.count() + stageConfig.objects.count()) + viewer->linkError = 3; + } else { + if (unknownScriptCount != 0) + viewer->linkError = 2; + if (unknownScriptCount == stageConfig.objects.count()) + viewer->linkError = 3; + } break; } case ENGINE_v3: { // compile RSDKDraw & RSDKLoad and draw via those @@ -3531,6 +3552,9 @@ void SceneEditor::InitGameLink() scriptPath); compilerv3->ParseScriptFile(scriptPath, scrID++); + if (!compilerv3->fileFound) + unknownScriptCount++; + if (compilerv3->scriptError) { PrintLog(compilerv3->errorMsg); PrintLog(compilerv3->errorPos); @@ -3563,6 +3587,7 @@ void SceneEditor::InitGameLink() compilerv3->objectScriptList[scrID - 1].subRSDKEdit.jumpTablePtr = -1; scriptError = true; + viewer->linkError = 1; } } } @@ -3573,6 +3598,9 @@ void SceneEditor::InitGameLink() WorkingDirManager::GetPath("/Scripts/" + stageConfig.objects[i].script, scriptPath); compilerv3->ParseScriptFile(scriptPath, scrID++); + if (!compilerv3->fileFound) + unknownScriptCount++; + if (compilerv3->scriptError) { PrintLog(compilerv3->errorMsg); PrintLog(compilerv3->errorPos); @@ -3605,8 +3633,20 @@ void SceneEditor::InitGameLink() compilerv3->objectScriptList[scrID - 1].subRSDKEdit.jumpTablePtr = -1; scriptError = true; + viewer->linkError = 1; } } + if (stageConfig.loadGlobalScripts){ + if (unknownScriptCount != 0) + viewer->linkError = 2; + if (unknownScriptCount == gameConfig.objects.count() + stageConfig.objects.count()) + viewer->linkError = 3; + } else { + if (unknownScriptCount != 0) + viewer->linkError = 2; + if (unknownScriptCount == stageConfig.objects.count()) + viewer->linkError = 3; + } break; } case ENGINE_v4: { // compile RSDKDraw & RSDKLoad and draw via those @@ -3623,6 +3663,9 @@ void SceneEditor::InitGameLink() scriptPath); compilerv4->ParseScriptFile(scriptPath, scrID++); + if (!compilerv4->fileFound) + unknownScriptCount++; + if (compilerv4->scriptError) { PrintLog(compilerv4->errorMsg); PrintLog(compilerv4->errorPos); @@ -3655,6 +3698,7 @@ void SceneEditor::InitGameLink() compilerv4->objectScriptList[scrID - 1].eventRSDKEdit.jumpTablePtr = -1; scriptError = true; + viewer->linkError = 1; } } } @@ -3665,6 +3709,9 @@ void SceneEditor::InitGameLink() WorkingDirManager::GetPath("/Scripts/" + stageConfig.objects[i].script, scriptPath); compilerv4->ParseScriptFile(scriptPath, scrID++); + if (!compilerv4->fileFound) + unknownScriptCount++; + if (compilerv4->scriptError) { PrintLog(compilerv4->errorMsg); PrintLog(compilerv4->errorPos); @@ -3698,8 +3745,20 @@ void SceneEditor::InitGameLink() compilerv4->objectScriptList[scrID - 1].eventRSDKEdit.jumpTablePtr = -1; scriptError = true; + viewer->linkError = 1; } } + if (stageConfig.loadGlobalScripts){ + if (unknownScriptCount != 0) + viewer->linkError = 2; + if (unknownScriptCount == gameConfig.objects.count() + stageConfig.objects.count()) + viewer->linkError = 3; + } else { + if (unknownScriptCount != 0) + viewer->linkError = 2; + if (unknownScriptCount == stageConfig.objects.count()) + viewer->linkError = 3; + } break; } } diff --git a/RetroEDv2/tools/sceneeditorv5.cpp b/RetroEDv2/tools/sceneeditorv5.cpp index b439de9..1100b78 100644 --- a/RetroEDv2/tools/sceneeditorv5.cpp +++ b/RetroEDv2/tools/sceneeditorv5.cpp @@ -2932,22 +2932,34 @@ void SceneEditorv5::CreateNewScene(QString scnPath, bool prePlus, bool loadGC, Q // Can't load objects properly on a new scene without Game.dll, so we REALLY need one bud. if (gameLinks.count() == 0){ QMessageBox dllMessage(QMessageBox::Information, "RetroED", - QString("Game.dll not found, select the location of the file"), + QString("Game library not found, select the location of the file"), QMessageBox::Ok); dllMessage.exec(); + QStringList extensionType = { "RSDKv5 Game Library (*Game.dll)", + "RSDKv5 Game Library (*Game.dylib)", + "RSDKv5 Game Library (*libGame.so)", + }; +#ifdef Q_OS_WIN + int definedOS = 0; +#elif Q_OS_MAC + int definedOS = 1; +#else + int definedOS = 2; +#endif - QFileDialog gdlldialog(this, tr("Locate Game.dll Folder"), "", - tr("RSDKv5 Game Library (Game*.dll)")); - gdlldialog.setFileMode(QFileDialog::Directory); + QFileDialog gdlldialog(this, tr("Locate Game library"), "", + tr(extensionType.at(definedOS).toStdString().c_str())); gdlldialog.setAcceptMode(QFileDialog::AcceptOpen); if (gdlldialog.exec() == QDialog::Accepted) { gameLinkPath = gdlldialog.selectedFiles()[0]; } else{ - SetStatus("Scene Creation Cancelled, no Game.dll found"); - AddStatusProgress(1); + SetStatus("Scene Creation Cancelled, no Game library found"); return; } - LoadGameLinks(); + UnloadGameLinks(); + GameLink link; + gameLinks.append(link); + gameLinks.last().LinkGameObjects(gameLinkPath); } } @@ -3467,7 +3479,52 @@ void SceneEditorv5::LoadScene(QString scnPath, QString gcfPath, byte sceneVer) AddStatusProgress(1. / 6); // finish setting up UI stuff - InitGameLink(); + if (gameLinks.count()) + InitGameLink(); + else { + switch (viewer->engineRevision) { + case 1: break; + + case 2: + for (int i = 0; i < viewer->objects.count(); ++i) { + if (gameConfig.readFilter) + FunctionTable::SetEditableVar(VAR_UINT8, "filter", i, + offsetof(GameEntityv2, filter)); + } + break; + + default: + case 3: + for (int i = 0; i < viewer->objects.count(); ++i) { + if (gameConfig.readFilter) + FunctionTable::SetEditableVar(VAR_UINT8, "filter", i, + offsetof(GameEntityvU, filter)); + } + break; + } + + QString backupVars = homeDir + "RSDKv5VarNames.txt"; + if (QFile(backupVars).exists()) { + for (int i = 0; i < viewer->objects.count(); ++i) { + for (int v = viewer->objects[i].variables.count() - 1; v > 0; --v) { + QString hash = viewer->objects[i].variables[v].hash; + QFile file(backupVars); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream txtreader(&file); + while (!txtreader.atEnd()) { + QString varBackup = txtreader.readLine(); + if (hash == Utils::getMd5HashByteArray(varBackup)){ + viewer->objects[i].variables[v].name = varBackup; + break; + } + } + file.close(); + } + } + } + + } + } QCheckBox *filterToggles[] = { ui->filterBox1, ui->filterBox2, ui->filterBox3, ui->filterBox4, ui->filterBox5, ui->filterBox6, ui->filterBox7, ui->filterBox8 }; @@ -3968,11 +4025,15 @@ void SceneEditorv5::LoadGameLinks() void SceneEditorv5::InitGameLink() { viewer->gameEntityList = NULL; - viewer->engineRevision = 3; + viewer->engineRevision = 3; + viewer->linkError = -1; - if (gameLinks.count()) { - GameLink &link = gameLinks.first(); + for (GameLink &link : gameLinks){ viewer->engineRevision = link.revision; + viewer->linkError = link.error; + // stop at the first valid gamelink + if (viewer->linkError == 0) + break; } switch (viewer->engineRevision) { diff --git a/RetroEDv2/tools/sceneviewer.cpp b/RetroEDv2/tools/sceneviewer.cpp index e323f3e..5d9b788 100644 --- a/RetroEDv2/tools/sceneviewer.cpp +++ b/RetroEDv2/tools/sceneviewer.cpp @@ -356,10 +356,56 @@ void SceneViewer::updateScene() .arg(selectedObject >= 0 && selectedObject < objects.count() ? objects[selectedObject].name : "[None]"); + QString gameLinkState; if (gameType == ENGINE_v5){ status += QString(", Selected Stamp: %1").arg(selectedStamp); if (engineRevision != 1) status += QString(", Filter: %1").arg(sceneFilter); + if (!v5Editor->gameLinks.count()){ +#ifdef Q_OS_WIN + gameLinkState = "No Game.dll found"; +#elif Q_OS_MAC + gameLinkState = "No Game.dylib found"; +#else + gameLinkState = "No libGame.so found"; +#endif + } else { + if (linkError > 0){ + switch (linkError){ + case 1: + gameLinkState = "Library is for the wrong architecture"; + break; + case 2: + gameLinkState = "Found library is not a valid Game Library"; + break; + default: + gameLinkState = "Found library is not a valid Game Library"; + break; + } + } else { + gameLinkState = "Game Link Loaded, Revision REV0" + QString::number(engineRevision); + } + } + status += QString(", Game Link State: %1").arg(gameLinkState); + } else { + if (linkError > -1){ + switch (linkError){ + case 1: + gameLinkState = "Scripts disabled due to parsing error"; + break; + case 2: + gameLinkState = "Partial Script Load"; + break; + case 3: + gameLinkState = "No Scripts found"; + break; + } + } + else { + gameLinkState = "Scripts Loaded"; + } + if (gameType != ENGINE_v1) + status += QString(", Game Link State: %1").arg(gameLinkState); } status += QString(", FPS: %1").arg(avgFps, 0, 'f', 1); statusLabel->setText(status); @@ -1676,7 +1722,7 @@ void SceneViewer::processObjects(bool isImage) sceneInfoV1.entitySlot = 0; for (int e = 0; e < entities.count(); ++e) { if (entities[e].gameEntity) { - AS_ENTITY(entities[e].gameEntity, GameEntityvU)->onScreen = 0; + AS_ENTITY(entities[e].gameEntity, GameEntityv1)->onScreen = 0; } } @@ -1785,7 +1831,7 @@ void SceneViewer::processObjects(bool isImage) sceneInfo.entitySlot = 0; for (int e = 0; e < entities.count(); ++e) { if (entities[e].gameEntity) { - AS_ENTITY(entities[e].gameEntity, GameEntityvU)->onScreen = 0; + AS_ENTITY(entities[e].gameEntity, GameEntityv2)->onScreen = 0; } } diff --git a/RetroEDv2/tools/sceneviewer.hpp b/RetroEDv2/tools/sceneviewer.hpp index 2cee6a3..def2431 100644 --- a/RetroEDv2/tools/sceneviewer.hpp +++ b/RetroEDv2/tools/sceneviewer.hpp @@ -111,6 +111,7 @@ class SceneViewer : public QOpenGLWidget // Stuff for game link int engineRevision = 3; + int linkError = -1; SceneInfo sceneInfo; EngineInfo gameInfo;