Compare commits

..

365 Commits

Author SHA1 Message Date
briaguya a133be625e chore: bump version 2022-10-06 20:06:27 -04:00
aMannus 06e8a5af41 Fix navi colors in cosmetics editor (#1684)
* Fix navi colors in cosmetics editor

* Fix navi description for props
2022-10-03 20:50:05 -04:00
th-2021 f1070a2e74 set version in build.c from CmakeLists.txt version info (#1678) 2022-10-04 01:13:29 +02:00
Garrett Cox 02c0caff4f [#1567] Fix merchant message table being generated before items were loaded from save (#1674) 2022-10-03 08:50:19 +02:00
Garrett Cox 2ad0b37fa5 [#1675] Fix for business scrubs crashing on expensive scrub shuffle (#1676) 2022-10-03 08:49:53 +02:00
aMannus 6b6a352205 Rando: Fix "Scrubsanity Off" using mysterious text (#1679) 2022-10-02 20:32:05 +02:00
Ada 37ffc8b9c8 Fixes Y-Axis inversion in C Up view 2022-10-01 19:19:23 -04:00
louis d75b38d457 fix MQ forest 2022-10-01 17:55:03 -04:00
briaguya 36e40665bb fix: don't hardcode path for global.sav (#1656)
Co-authored-by: briaguya <briaguya@alice>
2022-10-01 19:48:46 +02:00
briaguya 9804035dc0 fix: match auto center option text to behavior 2022-10-01 13:46:58 -04:00
briaguya 973ec52b2a chore: increment version to bravo 2022-10-01 13:46:27 -04:00
louis d61b398f41 Fix MQ not going away after deleting file 2022-10-01 13:22:24 -04:00
briaguya af13595aae fix: disable randomizer cvar when in master quest 2022-10-01 13:13:07 -04:00
GaryOderNichts 97211093f3 Wii U: Fix overflow for GX2CopySurfaceEx (#1655)
The max amount of rects is 25, everything larger silently overwrites the stack
2022-10-01 18:06:00 +02:00
Ada 15e22349df Fixes Master Quest on Mac and Linux (#1641) 2022-09-30 20:24:59 +02:00
briaguya 8888fb2ec1 Master Quest (#3) (#1632)
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>

Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>
2022-09-29 19:07:48 -04:00
louist103 dc3c0dd9c8 disable crit wiggle (#1629)
* disable crit wiggle

* Set to zero in default preset
2022-09-28 20:27:07 -04:00
aMannus 08915e5684 Update description for CC (#1626) 2022-09-28 02:40:29 -04:00
David Chavez 083ceb4423 Feature: Crowd Control Integration (#1568)
* Start effects

* Disable input to game when typing in console

* Add gravity support

* noUI placeholder

* Add rest of effects to console

* Remove z_play code

* Add rupee modification

* Add OneHit KO (#27)

* few fix and paper Link

* Better method and now use the reset flag

* Revert "Better method and now use the reset flag"

This reverts commit 2aafcc1df2.

* Revert "few fix and paper Link"

This reverts commit 65e76dcfee.

* Paper Link & few fixes (#28)

* Implement pacifist mode (#30)

* Implement cucco storm (#31)

* Add no UI functionality (#32)

* Enable CrowdControl on windows (#33)

* Use std::format and implement wallmaster

* Implement defense modifier

* Implement no_z and clean up

* Implement reverse controls

* Some fixes while testing CC connection

* Implement speed modifier and fix defese modifier

* Fail magic effects if magic is not acquired

* Fix queue system

* Implement rainstorm

* Some cleanup

* Use IS_ZERO to handle very low near zero values

* Split some effects

* Fix emptying magic

* Don’t run cucco on pre-rendered backgrounds

* Use correct method for updating ruppees

* Fix decreasing speed

* Remove old SDL stuff

* Remove old fixes

* Enable Crowd Control for both debug and release

* Add missing returns

* Cleanup event firing

* Further clean up on event firing

* Fix some bugs

* CC fixes and enemy spawning (#35)

* Fix icetraps

* Fix title screen

* Fix pause screen

* Fix death screen timer & Code cleanup

* Fix timer during textboxes

* Code cleanup

* Add: Multiple enemy spawning

* More enemies + more code cleanup (#36)

* Enums for returning effect states

* Add more enemies

* Update CrowdControl.cpp

* Remove enums from enemies

* Fix up flow for events (#37)

# Conflicts:
#	soh/soh/Enhancements/crowd-control/CrowdControl.cpp

* Fix spawn position of likelike

* CC temp enemy fixes (#38)

* Check for pause in pacifist and allow button presses (#39)

* Fix Pacifist mode (#41)

* First attempt pacifier fix

* Real fix for pacifist mode

* Comment

* Remove cutscene and long delay from cucco_storm (#40)

* Some PR Fixes

* Use standard types

* Handle JSON parsing error and free memory

* Add CC configuration file

* Add: Giving deku shield option. Fix: Giant Lonk (#42)

* Small stalfos fix (#43)

* Syntax Improvements (#44)

* Revert bools to uint32_t

* Add comment about bools

* Fix cucco storm, fix empty heart (#45)

* Protect commands vector with mutex

* prefix effects with chaosEffect (#46)

Co-authored-by: briaguya <briaguya@alice>

Co-authored-by: Baoulettes <perlouzerie@hotmail.fr>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
Co-authored-by: briaguya <briaguya@alice>
2022-09-27 22:41:17 -04:00
PurpleHato 87125ae334 FIX: Sword Trail not appearing when using custom color (#1625)
This was caused by the trail duration not being init properly until we change the duration manually.

cf this video: https://streamable.com/a9u4fm

- Also changed Lengh to Duration for clarity
2022-09-27 20:58:25 -04:00
Garrett Cox c487e4ba0b Shopsanity - fix regression from removing BUY_BOMBCHU_5 (#1624) 2022-09-27 19:56:25 -04:00
PurpleHato 1b141fd68c FIX: Missing custom colors on ENTER NAME (#1623) 2022-09-27 19:33:01 -04:00
PurpleHato 694c6c9832 FIX: Set back default comportment of some Views (#1615)
* FIX: Set back default comportment of some Views

- Renamed Auto-Center First Person View to Disable Auto-Centering in First Person View and make it necessary to be checked to take effect and not being active by default

- Disable gInvertYAxis being enabled by default (which it not vanilla)

* Tweak: small whoopsie
2022-09-27 19:32:28 -04:00
GaryOderNichts c6a875eb5c Change precision of float sliders (#1609)
* Change precision of float sliders

* Formatting

* Don't round non-percentage sliders
2022-09-27 19:30:50 -04:00
GaryOderNichts 677c4845f6 Wii U: Several fixes and improvements (#1608)
* WiiU: fix more scaling issues

* Wii U: batch depth reads

* Wii U: remove file buffering
Doesn't seem to to do much anymore

* Remove "missing_gcc_functions.c" to avoid conflicts

* Wii U: Fix random_device usage
random_device will always be seeded with a constant seed and will return the same number sequence every time

* Wii U: Improve software keyboard

* Wii U: Fix console input text width
2022-09-27 19:29:55 -04:00
Garrett Cox 7fb8902e7f [#1613] Resolve double message issue for gold skulltula tokens after you've spoken to skulltula parent (#1616) 2022-09-27 19:44:52 +02:00
louist103 58c097cfb9 Add a few meme hints (#1544)
* Add a few meme hints

* more
2022-09-26 23:07:57 -04:00
Garrett Cox 6265613bc7 Correct default value of gInvertYAxis and change default trials required to vanilla (#1610) 2022-09-26 20:09:01 -04:00
louist103 c21b2e8f00 Crash Handler 2.0 (#1466)
* Linux side done

* Win V2. need to fix message box.

* Fix message box.
2022-09-26 19:54:25 -04:00
Garrett Cox b3c7edcf76 [#1603] Ensure gFasterHeavyBlockLift only affects large silver rocks (#1607) 2022-09-26 19:51:19 -04:00
Garrett Cox c2ff12c3e8 [#1584] Undo the special rotation done for spiritual stones after they are purchased so the sold out sign isn't sideways (#1606) 2022-09-26 19:50:49 -04:00
David Chavez dbc4d8199e Feature: Allow choosing audio backend (#1588)
* Fix X11 being searched for on macOS

* Add ability to switch audio backends

* Fix issues with c arrays of std dynamic size items

* Fix old uses of sizeof()

* Remove current selected option from list

* Don’t show items if we only have one option
2022-09-26 19:48:47 -04:00
Garrett Cox 0e1248f840 [#1602] Fix crash when attempting to render a non-randomized item in bombchu bowling (#1604) 2022-09-27 00:24:19 +02:00
Garrett Cox 7a516c72c3 [#1597] Remove Buy Bombchu (5) from pool, 3ds-only shop item (#1605) 2022-09-27 00:23:49 +02:00
Christopher Leggett a927a881fc Fixes Happy Mask shop on the Switch. (#1591) 2022-09-27 00:05:46 +02:00
amekusa ac1a87730e [macOS] Fix launcher code in case with 'sysctl.proc_translated' returning empty (#1598) 2022-09-26 22:12:45 +02:00
Rozelette cf881d7d25 Fix Gohma disintegration (#1593) 2022-09-26 17:53:22 +02:00
Christopher Leggett 41eb6c585d Excludes the master sword in the Ganon Battle from triggering autosave. (#1594) 2022-09-26 17:52:53 +02:00
Christopher Leggett ee505fc47d Fixes ocarina textbox flashing (#1589) 2022-09-26 09:01:58 +02:00
aMannus 7758749770 Removed d-pad support for pause in preset (#1592) 2022-09-26 08:45:59 +02:00
GaryOderNichts da893a5b86 Fix save corruption on switch (#1585) 2022-09-25 12:19:53 -04:00
David Chavez e412a8b55e Only attempt to compile PulseAudioPlayer on Linux (#1581) 2022-09-25 12:18:26 -04:00
Rozelette 5a0b854c5c Fix Phantom Ganon not disintegrating (#1579) 2022-09-25 12:18:06 -04:00
Rozelette bf2420f7d3 Fix Ganondorf texture issues (#1578) 2022-09-25 12:16:16 -04:00
RaelCappra 50d6836b4a assert __THROW fix for Linux (#1575)
* assert __THROW fix for Linux

* Add check for Linux in changed definition
2022-09-25 12:15:36 -04:00
Garrett Cox da677682cd Don't disable keyboard when menuBar is shown and gControlNav is true (#1566) 2022-09-25 12:14:46 -04:00
David Chavez 11b6ce819d Update version in other remaining spots (#1558) 2022-09-25 12:13:23 -04:00
David Chavez 5ee86cb558 Remove obsolete and outdated xcode project (#1557) 2022-09-25 12:13:00 -04:00
David Chavez 3a2fcc9604 Handle window closing event to stop SoH (#1556)
* Handle window closing event to stop app

* Address PR comments
2022-09-25 12:12:38 -04:00
Jeffrey Crowell fde05e65c0 [macOS] Force native architecture to launch (#1554) 2022-09-22 13:30:47 +02:00
David Chavez 00fb12134a Fix macOS minimum deployment target (#1551) 2022-09-22 07:58:42 +02:00
David Chavez fa8d64ec3a Disable game input when typing into a textfield (#1398)
* Disable game input when typing into a textfield

* Only block keyboard input when typing in textfield

* Address PR comments

* Fix spacing

* Generalize check on input device

Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
2022-09-21 21:32:27 -04:00
Adam Bird b4740d131f reset gyro drift when gyro is turned off (#1542) 2022-09-21 21:29:35 -04:00
Garrett Cox ec2222347e Fix issue with 'auto' controller setting (#1548)
* Fix issue with 'auto' controller setting

* Combine inputs rather than overwrite for auto setting

* Swap condition checking for zeroed pads
2022-09-21 21:29:16 -04:00
Josh Bodner 3d0d97d6b5 Fix crash when creating rando files and autosave is enabled (#1550) 2022-09-22 00:28:07 +02:00
briaguya 2b78bea475 Randomizer v2 (#1065)
* Revert changes to GetItemFromGet

* Fixes Ganon's Boss Key shuffled while regular boss Keys aren't.

* Enum + combo box

* Add obtainability checks correctly

* combobox title rename + no number tracking

* Fix repeatable purchases and bottles rendering incorrectly

* Move shopsanity option in GUI

* Struct instead of ImVec + basic comportment for all case

* Attempt to fix odd build issue

* Cast randoGet for ganons boss key

* Remove redundancy in KD room

* Update logic Cvar names

* Fix Ganons Trials coming from old save files. Fixes #1365

* Fixes crash when entering Ganon's Castle lobby on linux.

* Makes `Item_Give` safe to use with a NULL globalCtx.

This should allow it's use for giving items to Link's Pocket
during rando save initialization.

* Converts Song from Impa to use `Item_Give`

* Adds more options for Link's starting item.

* Removes unneeded `GiveLinkItem` functions.

* and make it build

* bring back new rando dropdown

* gSaveContext access in GameMenuBar.cpp

* Implement Skip Scarecrow's Song

* Reimplement progressive Bombchus

* Rando-next: Deku Nut and Seed ammo gives a blue rupee
Fixes #1390

* Fixes Link starting with BGS

* Persist item tracker notes

* Adjust Hooks include

* Use SohImGui::RequestCvarSaveOnNextTick

* Fix issues from LUS refactor

* Fix for overriding deku scrub messages

* Fix mistake from merge

oops

* Restore checkboxes to enhancements menu

These got lost in the merge

* Update location access logic

Including MQ locations in Spirit and GC now

* Implement rando bombchu drops

* Missing break

* Simplify mudwall collision check

There was no need to have a second collider specifically for Ice Arrow hits

* Update settings.cpp

* Simplify mudwall collision check

* Restore checkboxes in menu

Accidentally lost these during merge

* Clean up bool

* Update logic Cvar name

* Fixed capacity on ammmo tracking

* Fix for beans obtainability

* Hook into file delete and clear notes

* Incorporate magic arrows in rando settings

* Update tooltip

To inform the player that they might have to reload the room if they're enabling this for the first time.

* Update tooltip

* Add line break in tooltip

* Tooltip wording + line break

* tweak on main logic

* All color logic for all types

* Fix: changes to please new LUS

* Ensure itemTrackerNotes vector is not fully empty

* Implement's Tycoon Wallet.

* Refactor DrawItemCount and Use EnhancementCombobox for tracker capacity options

* small tweaks and rename

* always display XX/YY when in ammo/capacity mode

* Move all merchant messages to be generated on file load

* added hovertext for the number display

* Swap german and french translations for shop messages

* Set key colors to be on by default

* Add another flag to skip mask shop

* Fix Sold Out bug

* Fix gerudo keys, add disabled checkbox

* tooltip line break

* Add trials required and merchant prices to save file instead of loading from active spoiler log

* Remove trialsRequired persisting in save manager

* Adds slotIndex to girla (shop item actor) and uses that for IdentifyShopItem.

* Fix issue when merchantPrices is empty

* Fix for a single zeroed merchantPrice entry

* Fix #1417

* Implements items selling out and fixes issues with purchasing some items.

* Fixes order of operations so Rupees will be spent.

* Fixes sold out items not getting overwritten by the randomized info.

* Clarify var names and comments

Also preserve chain platform cutscene in spirit based on Link's position

* Remove !=0 from cvar check

* Clarify var names and comments

* Rename randomizerMerchantPrices to merchantPrices

* Handle shop items in SaveManager

* Fix merge mistake

* Base whats in the bazaar shop on entranceIndex instead of age

* Tidy up chain platform cutscene check

* Fix merge error

Didn't mean to have Zhora changes in here yet

* Use 3drando item table for parsing spoiler names

* Use another nested method instead of one at the top level to fetch the table

* Add missing newline

* Remove log

* Respect custom draw functions

* Fix issues with rendering songs

* Fix localized item names for shopsanity

* Implements a larger array of Sprites for the Icon Hash.

* Uses the hash instead of seed for spoilerfile name and icons.

* Removes some unused functions and variables in `spoiler_log.cpp`

* Prevents leading 0s added to hash from being in file name

* Changes filename format to icon indexes separated by dashes

* Hopefully makes Jenkins happy

* Hopefully makes Jenkins happy

* [Rando] Child Gerudo Fortress 37th Heartpiece randomized
Fixes #1071

* Add descriptions to save editor flags editor, and added randomizer flags (#1386)

* Add descriptions to save editor flags editor, and added randomizer flags

* Hide randomizer flags when not on a randomizer save

* Move flag descriptions to header file

* Update soh/soh/Enhancements/debugger/debugSaveEditor.h

* Update soh/soh/Enhancements/debugger/debugSaveEditor.h

* Fix merge error

* crash on pause menu on linux (only in appimage)
Fixes #1437

* Applies fix to Song from Impa as well.

* Allow buying tunics as child when shopsanity is on

* Fix for custom draw methods overriding sold out sign

* Simplify logic around shopsanity and fix some issues

* Fix dungeon reward stone rotation and add particles

* Fix some issues with ice traps

* Fix adult wallet having its own max capacity

* Fix amount of keys given for BotW

* format

* Use EnGirlAShopItem enum instead of raw hex values

* [#1434] Renders non-warp songs more consistently with warp songs

* A few changes around merchant messages

* Various changes from PR feedback

* Rando: Junk Hint missing french translation

* Typo

* Fix free scrub being at 0 instead of TEXT_SCRUB_RANDOM

* Replace magic numbers in message handler

* Update soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>

* Update soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>

* Fix BGS softlock for shopsanity

* Support tycoon wallet on tracker

* Revert "Fix BGS softlock for shopsanity"

This reverts commit 5fdb961ea4.

* [#1053] Resolves an issue with shop items and bombchu bowling where BGS would display two message boxes

* Implements some necessary plumbing and resolves several Ice Trap Softlocks.

Adds a way for an item entry to tell what type of check it came from (NPC vs Chest vs Freestanding, etc.)
Sets this value from chests and item00 actors.

Relocates pendingIceTraps to save context so it can persist through cutscenes and get stored on save init for Link's Pocket and Song from Impa.

Restructures pendingIceTraps into a counter rather than a true or false, so that we can be frozen multiple times in a row if applicable (atm that should only be at the start of a run if Link's Pocket and Song from Impa were both Ice Traps).

Adds a textbox for Ice Traps and a special case of holding up nothing in the get item process. This fixes all the cases where Ice Traps would softlock due to the actor giving the item expecting a closing textbox. After holding the item above his head Link increments the pendingIceTraps counter by one and sets whatever flag he has pending.

None of the above plumbing applies to Ice Traps from chests, those work exactly the same as before, as do freestanding item00 ice traps (thanks to the additional check for ITEM_FROM_FREESTANDING.

OoT and Ruto's Letter count as NPC's, so they get the FOWL text box and set a pending ice trap rather than immediately freezing, since Link weill be in the water. Link will get frozen the next time he touches land, which in the case of OoT is after the fade to white and right before the Song of Time check.

Fixes all the other softlocks I'm aware of, including Fishing, Bombchu Bowling, Skull Kid, and losing the second Gerudo Archery check.

* fix bgs check in player

* move bgs logic for tokensanity into MOD_NONE check

* set bgs flag before `Item_Give`ing

* move bgs flag into `MOD_NONE` check in girla

* use existing check in `z_player`

* Adds comment explaining the decision to default ITEM_FROM_NPC.

* Rename pendingIceTraps to pendingIceTrapCount

* Adds some RANDOTODO comments about cleaning up a couple things.

* Merge branch 'develop-zhora' into ztornn

* manually restore changes to `z_player.c`

* Fix after some ice trap prepwork from earlier

* Actual fix

* Woops

* More rupee names

* Actually fix it

* Add back comment

* Fix Skip Scarecrow Song

* Fix ruto's letter and LH sun stick rendering

* Also fixes it for treasure chest game

* Tweak: Rando French Wallet

* ADD: French Tycoon

* Hide dungeon items/notes by default

* [#1301] Fix issue with UI not restoring after getting an item from biggoron

* Update soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c

* Update soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c

* Fix random crash that only affected one person for some reason

Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Sarge-117 <adam_branston@outlook.com>
Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: lil David <1337lilDavid@gmail.com>
Co-authored-by: Sarge-117 <108380086+Sarge-117@users.noreply.github.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
2022-09-21 00:50:22 -04:00
louist103 28b7f23769 Update extractor.cpp (#1541) 2022-09-21 00:38:54 -04:00
Christopher Leggett 784cb98d7f Cosmetics editor fixes (#1538)
* Fixes randomize all and randomize section buttons.

* Fixes individual randomize cosmetics buttons

* Fixes Navi Colors

* Inits srand(time(NULL)) for each individual randomize buttons
2022-09-21 00:17:04 -04:00
Garrett Cox d47746eab1 Fix issue with simulated input lag (#1535) 2022-09-20 23:25:01 -04:00
Garrett Cox 936c493b9e Add cheat for easy pause buffering (#1439)
* Add cheat for easy pause buffering

* Add pause input buffering

* Fix pause input buffering

* Changes from feedback

* Convert frame to bool

* Handle when pad is nullptr

* Add newline

* Split input buffering into it's own CVAR

* Split SetShouldBlockGameInput up into to methods
2022-09-20 23:24:06 -04:00
Kenix3 d628bafe29 Removes console from Windows release builds. (#1536) 2022-09-20 23:23:47 -04:00
MoriyaFaith d83c6f1753 [Bugfix + Enhancement] Sword Trail fixes and enhancements (#1473)
* Fix Trails, add more Trail Customization

* 3d Bombs; Bombchu now glow custom trail colors

* 3D Seed/Nut Model, Separate Sword Slash Colors

* Removed 3D Seeds/Nuts; Don't work properly

* restored previous removal of sword blur code

* Remove things not related to Trails

* Remove fix to random color code
2022-09-20 22:49:31 -04:00
Christopher Leggett e1b83b6eb4 Fixes crash on Switch/WiiU when attempting to show the ImGui menubar. (#1534)
* Fixes crash on Switch/WiiU when attempting to show the ImGui menubar.

* Fixes weird indentaion on GitHub?
2022-09-20 21:15:15 -04:00
Christopher Leggett d2153d601c Fixes Restore Old GS Cutscene to only trigger on Gold Skulltulas. (#1529) 2022-09-20 21:11:10 -04:00
aMannus 98be9a8472 Fix vanilla sun's song grave bug (#1532) 2022-09-20 20:09:23 -04:00
Josh Bodner 5d2b5559c8 Autosave improvements (#1247)
* Autosave improvements

* Update soh/src/code/z_play.c

* Removes a line break in building.md

Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
2022-09-20 20:08:43 -04:00
Josh Bodner b54f6daa27 Consolidate D-pad CVars and clean up presets (#1298)
* Consolidate D-pad CVars

* Update other tooltip

* Clean up presets

* Fix incorrect preset value

* Undo crouch
2022-09-20 08:15:07 +02:00
Christopher Leggett c5acef2957 Fixes laggy text boxes in Switch (#1527)
* Refactors message texture invalidation to remove lag on Switch.

* Removes unneeded commented out function calls.
2022-09-20 08:12:31 +02:00
Dan Lilja b5b5a58302 Bugfix/version file creation (#1475)
* Added creation of version file to OTRExporter

* Removed creation of version file from other places

* Made path to version file portable

* Changed spaces to tabs in OTRExporter/Main.cpp
2022-09-19 23:36:34 -04:00
Kenix3 d6d7ffd3da Update README.md 2022-09-19 23:27:16 -04:00
Rozelette 66c2fdaacd Fix unused dynamic link shadow for possible future enhancement (#1495)
* Fix unused dynamic link shadow for possible future enhancement

* No longer removing pritns

Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
2022-09-19 23:24:13 -04:00
MoriyaFaith f6fa3c74c7 Main commit (#1369) 2022-09-19 23:13:59 -04:00
MoriyaFaith 22c963c0a0 only change (#1474) 2022-09-19 23:06:51 -04:00
Josh Bodner e97ba37a5e Port Dampe behavior to vanilla (#1364)
* Port Dampe behavior to vanilla

* Add Dampe winning to Enhanced preset
2022-09-19 22:58:10 -04:00
briaguya b18cc9d628 Temporary Fishing Fixes for rando (#1525)
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: briaguya <briaguya@alice>
2022-09-19 22:55:46 -04:00
Christopher Leggett 978b325a30 Fixes save lag on Switch (#1499)
* Greatly improves saving speed on the Switch.

* Fixes build on non-switch platforms.
2022-09-19 22:53:38 -04:00
qurious-pixel 006506240f [APPIMAGE] Disable AppImageLauncher integration (#1469) 2022-09-19 22:53:05 -04:00
Garrett Cox f712068a17 [579] Add simulated input lag option (#1438)
* [579] Add simulated input lag option

* Continue to clear buffer when inputs are blocked

* Changes from feedback
2022-09-19 22:49:13 -04:00
Josh Bodner 55e79cd9d2 Add ability to disable fish randomly escaping 2022-09-19 22:31:40 -04:00
Rozelette c9aafcf7c5 Add hack to load bss texture in ovl_En_Jsjutan (fixes #69) (#1482)
* Add hack to load bss texture in ovl_En_Jsjutan

* Remove (debug?) reference to jsjutanShadowTex in LUS
2022-09-19 22:30:27 -04:00
Garrett Cox 34d6212ab2 [#1336] Fix issues with gFasterHeavyBlockLift (#1476) 2022-09-19 20:08:47 -04:00
louist103 e76890a796 Update XMLs from upstream (#1448)
* litle less than half way

* done?

* revert ganon for now

* anime1

* anime 2-3

* object_ganon

* rest of gaBon

* missed some changes

* player
2022-09-18 23:29:24 -04:00
Christopher Leggett e2e0a070ea Fixes copying save files on the switch (#1478) 2022-09-16 18:23:31 +02:00
aMannus d53c8588e2 Fix: Unbreak Wii U sliders (#1486)
* Unbreak Wii U sliders

* #elseif -> #elif
2022-09-15 16:48:51 -04:00
briaguya 941cf65227 use strnlen for c string empty check (#1352)
* use strcmp for c string compare

* Update z_file_choose.c

Co-authored-by: briaguya <briaguya@alice>
2022-09-13 21:12:03 -04:00
aMannus e1f95a5ad9 ImGui Switch/Wii U slider fixes (#1371)
* Switch/Wii U slider fixes

* Attempt at better spacing

* Updated after ImGui merge
2022-09-13 20:47:00 -04:00
lilDavid 18a26b480e Use Color_RGB8 CVars in z_message_PAL (#1372) 2022-09-13 20:45:51 -04:00
Christopher Leggett 67bbeca809 Another fix for getting items near critters. (#1332) 2022-09-13 20:45:23 -04:00
Josh Bodner eda5a6ac91 Fix blocks not being pushed all the way (#1363) 2022-09-13 20:38:26 -04:00
Kenix3 a2d4f4766d Fixes crash handler for jenkins builds. (#1445)
* Fixes crash handler for jenkins builds.

We must include the pdb in redistributables.

* Properly selects PDB file path for inclusion

Co-authored-by: Christopher Leggett <chris@leggett.dev>
2022-09-11 23:15:10 -04:00
Sarge-117 a9f3aedf8e Enhanced Magic Arrows (non-rando) (#1376)
* Add magic arrow enhancements, non-rando

Changes to red ice actor, sun switch actor, and mudwall actor to adjust their collision

* Update tooltip

* Simplify mudwall collision check

* Restore checkboxes in menu

Accidentally lost these during merge

* Update tooltip

* Add line break in tooltip

* Clarify var names and comments

Also preserve chain platform cutscene in spirit based on Link's position

* Remove !=0 from cvar check

* Missed a couple

* Clean up chain platform cutscene check
2022-09-08 22:58:08 -04:00
lilDavid 9686a7ca4c Add Items submenu to Enhancements > Gameplay (#1410) 2022-09-08 22:57:09 -04:00
GaryOderNichts e80e3440e1 wiiu: package SoH as a homebrew bundle (#1427) 2022-09-08 22:55:55 -04:00
Kenix3 4cda92462a Lowers severity of resource manager logging. 2022-09-08 20:25:44 -04:00
Kenix3 4a0269b3b1 Increment version 2022-09-08 19:10:03 -04:00
louist103 4d81c28738 boxes (#1428) 2022-09-08 19:05:16 -04:00
aMannus 3b844375b7 Add missing pendingFlags (#1414) 2022-09-06 11:27:26 +02:00
aMannus f1dc980de8 Fixed autobreak after ImGui cleanup 2022-09-03 05:52:01 -04:00
briaguya 6daf357fd9 fix include fix build (#1385)
Co-authored-by: briaguya <briaguya@alice>
2022-09-03 02:13:20 -04:00
Baoulettes d2fa0d6485 Rando: Fix Fast File Select seed loading (#1252)
* FixRandoLoading

* better methode
2022-09-03 01:33:24 -04:00
Ada b14fb37b81 Update libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp
Co-authored-by: David Chavez <david@dcvz.io>
2022-09-03 01:33:24 -04:00
Ada edb5261b07 Fixes ToT Fog 2022-09-03 01:33:24 -04:00
louist103 8118947ab0 Windows crash handler. (#1383)
* Windows crash handler.

* Fix naming convention.
2022-09-03 01:15:43 -04:00
David Chavez 0ce0ab1260 Phase 1: Separate ImGui Drawing From LUS (#1310)
* Update LUS imported paths

* Introduce GameMenuBar

* Fix imports after LUS import paths change

* Move Randomizer

* Replace needs_save

* Migrate Developer Tools

* Migrate Cheats

* Migrate Enhancements

* Separate UIWidgets

* Add missing Hooks.cpp file

* Migrate Settings

* Remove UI methods from LUS

* Cleanup imports and exposed properties

* Cleanup more methods

* Fix project generation

* Fix CI compilation

* Remove resolved TODO
2022-09-03 00:00:04 -04:00
Christopher Leggett 64aca78450 Fixes Switch/Wii U crashes with Wonder Rupees and Bottleable Entities (#1360)
* Reorders switch statement to prevent some code that shouldn't execute.

* Potentially fixes bottleable entities crash

* Solves lack of ItemEntry for GI_MAX

* Adds comment clarifying new GetItemEntry
2022-09-02 19:19:12 +02:00
louist103 584a4ad818 Linux crash handler (#1209)
* crash handler linux

* cleanups

* missing underscore

* more cleanups

* cleanups

* 32 bit
2022-08-31 22:59:38 -04:00
Christopher Leggett bf505dba5c Fixes keys, maps, and compasses on develop-zhora rando (#1338)
* Fixes keys, maps, and compasses on develop-zhora rando.

* Adds randotodo comment as a note to adapt for the keysanity situation.
2022-08-31 15:25:58 +02:00
Christopher Leggett 776219fb52 Backports a fix for sheik checks from rando-next (#1340)
* Fixes some Sheik checks I had accidentally set the wrong flag for.

* Removes duplicate switch case from cherry-pick
2022-08-31 15:25:47 +02:00
Christopher Leggett a572c11f4f Fixes ice trap gidata not getting cleared after trap is sprung. (#1322) 2022-08-27 09:27:20 +02:00
Christopher Leggett 05136c13b7 Fixes Link getting Song as pocket item (#1326) 2022-08-27 02:46:19 +02:00
Christopher Leggett c2fed1a382 Fixes Lost Woods Bridge Ice Trap in Rando (#1313) 2022-08-25 20:16:43 +02:00
Christopher Leggett 90067be132 Fixes Dungeon Rewards from Song from Impa (#1311) 2022-08-25 17:19:17 +02:00
Kenix3 80863fc7f2 Moves class member functions from headers to compilation units. 2022-08-24 23:06:23 -04:00
Baoulettes c0b9171f98 Cosmetics Editor Fixes (#1287) 2022-08-25 01:28:27 +02:00
Ada b70ad81f57 Add platform specific OTR instructions to readme (#1291) 2022-08-24 22:02:20 +02:00
Kenix3 0573a1b2ac Adds const to DirtyDirectory std::string 2022-08-23 20:38:22 -04:00
Kenix3 b774252f0c ResourceMgr now decreases priority of load messages to trace. 2022-08-23 20:38:22 -04:00
Kenix3 3792b03a7d Cleans up InputEditor class. 2022-08-23 20:38:22 -04:00
Jake Edvenson 927ffd0b8b Enhancement: Scarecrow song skip (#1183)
* Added Skip Scarecrow Song

Added in the option for if the user has the time saver for Scarecrow song enabled and has their Ocarina pulled out in range of Pierre.
Added Skip Scarecrow Song
New enhancement under time-savers that allows the user to only pull out their ocarina to summon Pierre.

* Added Default for Scarecrow summon

The scarecrow summon option now defaults to 0 and can be turned on individually. I haven't included it in any other presets so people don't feel like they're cheating.

* Checks if scarecrow song is in possession

* Fixed positional Scarecrow logic

* Fixed style
2022-08-23 20:30:06 -04:00
Baoulettes d6ebce068d fixes only (#1255) 2022-08-23 20:20:56 -04:00
lilDavid 4680641514 Add bombchu drops (#1257)
* Add bombchu drops

* Force 3D bombchu drops

* Move bombchu drop conditions for better clarity

* Fix grouping on chu drop condition
2022-08-23 20:14:17 -04:00
aMannus ca08680a12 Add: Ability to disable ImGui checkboxes (#1272)
* Added ability to disable checkboxes

* Renamed args, added disabledGraphic option

* Moved checkbox out of ImGui source
2022-08-23 20:13:15 -04:00
David Chavez 70d7d66d0c Add multiviewport support for SDL (#1275) 2022-08-23 20:12:40 -04:00
Ada d735616020 Adds game specific camera options (#1212)
* Adds inversion options

* Fixes compilation

* Adds options to new detailed control editor

* Fixes inversion on C-Up view

* Fixes right stick aiming

* Fixes right stick aiming again

* Adds tooltip function + tooltips to gamecontroleditor.cpp

* Fixes tooltip for X axis

* Uses LUS tooltip function instead of new one

* Adds padding to camera control editor

To fit more in line with other enhancement checkboxes
2022-08-23 20:12:14 -04:00
Christopher Leggett 168e84498f Rework Get Item Table to be more flexible for adding custom items (#1050)
* Adds ItemTableManager class.

* Implements new getItem table in game.

* Adds rando item table and way to differentiate tables in GetItemEntry.

* Adds rough ability to differentiate between rando and vanilla items.merge stashed changes from before develop-zhora merge

* Change ItemTableID to be uint16_t so we can use ModIndex for it.

* Should fix switch build

* Should fix switch build pt 2

* Adds new files to CMakeLists.

* Implements fixes for competing getItem calls.

* Correctly renders freestanding items

Particle effects are probably broken, need to fix them still, I pretty
much know how I would do that.

* Fixed Particle effects in the new getItem system.

* Fixes item fanfares

* Partially fixes Ice Traps

Obtaining a freestanding Ice Trap causes link to slide forward
and receiving one from an NPC plays the sound effect and damage
animation but doesn't freeze link.

* Some more partial ice trap fixing that wasn't pushed earlier

* Removes unused function override

* Replaces ::find with ::at and adds exception handling

* Removes some commented out code.

* Refactors rando's GetItemEntry array into two arrays.

One array is for the vanilla items that don't have GetItemEntries in
vanilla, the other is for rando exclusive items. They are stored in
separate arrays before getting added to the table so that we can apply
different modIndexes. The items in the first table have are handled
by the vanilla Item_Give, and the second table needed a custom
`Randomizer_Item_Give` function.

* Renames, relocates, and implements ModIndex enum.

* Removes now unused ItemIDs and GetItemIDs

Also makes all the necessary changes to other code that was still
using them indirectly through the GI to GID map that was removed.
There's quite a lot of changes here and I haven't had time to test them
yet.

* Re-implements GIMESSAGE_UNTRANSLATED as macro

* Removes commented out function.

* Throws exception if an invalid itemID is used

Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r943694857

* Removes ARRAY_SIZE in favor of ARRAY_COUNT

ARRAY_COUNT already exists in `macros.h`, I just didn't find it before.

Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r943153833

* Inverts CheckContainsRandoItem to CheckContainsVanillaItem.

Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r940895135

* Cleanup, bugfixes, removing the `- 1`s from `z_player.c`

* Fixes some funky formatting that got committed earlier.

* Adds else if to added fanfare sound cases.

Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r940112924 and https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r940113492

* Extends GetItemEntry to include getItemId

Also adapts some existing calls for both the entry and the id to only
get the entry.

* Extends GetItemEntry to include GID.

This allows for using it later when drawing freestanding items.

Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r943168136

* Rando-specific items use new textId again.

This got lost when merging develop-zhora in because I didn't have custom
messages merged when I started this.

* Sets global modIndex to MOD_NONE on scene load

Fixes a crash when buying items in shops due to them
not triggering the rando code that normally sets these items.
May have also been crashing vanilla playthroughs.

* Realized I had the bgm conditions wrong.

* Fixes "static drops" (i.e. sticks from withered babas)

* Fixes LACS/Prelude situation... again.

* Fixes too many arguments error.

Not sure why this didn't fail to build on Windows before.

* Fixes Link's Pocket items.

* Simplifies sram init for rando-specific items

* Fixes issues with approaching bottleable items.

* Fixes Ruto's Letter.

It was accidentally getting classified as a rando item.

* Should re-fix freestanding ice traps

* Makes freestanding items set player->getItemEntry.

This prevents freestanding items from setting the global modIndex.
This is part of a larger transition that needs to happen to switch
to setting getItemEntries for all of the rando items. This prevents
some things that set getItemId of GI_MAX from granting a Fire Medallion
when the global modIndex is MOD_RANDOMIZER.

* Makes sure we aren't using getItemEntry when not randoed.

* Replace Randomizer_GetRandomizedItemId with Randomizer_GetRandomizedItem and Randomizer_GetItemIdFromKnownCheck with Randomizer_GetItemFromKnownCheck

* Introduce some new methods and migrate most actors to them

* Fixes ocarina game skull kids to set player->getItemEntry

* Sets `z_en_box.c` to set `player->getItemEntry`

* Fix logical errors and migrate most of the rest of the rando checks to GiveItemEntryFromActor

* Use GiveItemEntryFromActorWithFixedRange in item00

* Fixes Anju to set player->getItemEntry.

* Add a few missing cases

* Additional fix for Skull Kid

* Fixes vanilla ice traps and randomized ice smoke

* Fixes rendering of treasure chest game items.

* Removes unused `Randomizer_GetItemIdFromGetItemId`.

* Cleans up an if statement for item00.

* Cleans up another if statement in item00

* This should fix a bug with the Gerudo Archery minigame.

I wasn't able to get the bug to happen after making this change.

* Documents our new GiveItemEntry fuctions.

* Uses more descriptive type name for ItemIDs for creating custom messages.

* Fixes potential issue with if statement.

* Fixes missed type change.

Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
2022-08-23 20:11:38 -04:00
th-2021 ed1708508a add SHIP_HOME (Linux) (#1210) 2022-08-23 22:29:28 +02:00
Christopher Leggett e12e1d67c6 Prevents optimizations for debug configuration on Windows. (#1270) 2022-08-23 09:32:49 +02:00
th-2021 d39a1a0bdf [macos] Embed dependencies for ZAPD in bundle (#1271) 2022-08-22 10:43:50 +02:00
InfoManiac742 f87f636828 Update BUILDING.md (#1228) 2022-08-21 22:14:05 -04:00
louist103 eed3942b81 Restore Gold skulltula CS from the "0.9" version (#1217)
* GS CS

* add to defaults
2022-08-21 22:11:23 -04:00
Ralphie Morell f5112a709a Add'l Console Commands (#1207)
* Added console commands

* Style conformance
2022-08-21 22:01:51 -04:00
PurpleHato f6bb46a0dc FIX: Disable Draw Distance, Miniboss music could still play in DC with Lizalfos under certain conditions (#1170)
Thanks @jbodner09 for the report 💯
2022-08-21 21:57:55 -04:00
Kenix3 51e4485966 LUS Cleanup: Merge Window and GlobalCtx2 classes. (#1259)
* Merges GlobalCtx2 and Window classes.

* Includes condition variable in File.

* add mac specific include

* sstream to get past "implicit instantiation of undefined template" error

* switch/wiiu includes

* that file doesn't exist

* more wii u globalctx2 stuff

Co-authored-by: briaguya <briaguya@alice>
2022-08-21 21:08:01 -04:00
briaguya ad8179287e Fix controller nav on WiiU (#1258)
Co-authored-by: briaguya <briaguya@alice>
2022-08-20 02:03:28 +02:00
briaguya 0971b9aa78 only toggle menu with controller when controller nav enabled (#1043) 2022-08-19 15:46:11 +02:00
qurious-pixel 9bc6aac81e MacOS OTR (#973) 2022-08-18 19:40:41 +02:00
Kenix3 ad3efccb88 Merge pull request #1241 from GaryOderNichts/fix/wiiu-stick-input
Fix Wii U stick input
2022-08-17 17:54:33 -04:00
GaryOderNichts f4c1332159 Fix Wii U stick input 2022-08-17 17:27:33 +02:00
Kenix3 72981221ad Merge pull request #1226 from HarbourMasters/develop-rachael
rachael -> zhora
2022-08-16 23:40:06 -04:00
Kenix3 6723f4c7c2 Archive.createArchive error now passes in the error to SPDLOG. 2022-08-16 23:30:20 -04:00
Kenix3 f9621dcc17 Cleans up Window class. 2022-08-16 23:30:20 -04:00
Kenix3 10ce3c88fb Remove TestApp from LUS 2022-08-16 23:30:20 -04:00
Kenix3 ea92a2e123 Makes data in OverlayCommand private. 2022-08-16 22:45:33 -04:00
Kenix3 b43eb2d0bd Renames Camera Stick to Right Stick 2022-08-16 22:45:33 -04:00
Kenix3 d09172d74d LUS Cleanup: Fixes SDL axis handling. (#1220)
* Fixes SDL axis handling.

* Removes sensitivities from LUS

Should be a game specific feature.

* Updates Wii U Controllers to remove sensitivity

Also loads legacy controller profiles.

* Fixes memory leak in gfx_dxgi_get_key_name

Also fixes issue where wchars would be returned in dxgi when getting a key name.
2022-08-16 21:53:45 -04:00
David Chavez 6b0338a37d [zret] Port some documentation changes (#1164)
* zret: Documentation pass on scene/room commands #1226

* Update OTR scene

* zret: Document the lens system #1079

* zret: Misc. doc/cleanup 4 #1093

* zret: Fix misc 8 #1150

* zret: Document Distortions from z_camera and z_view #1102
2022-08-16 21:53:28 -04:00
briaguya 6206cd7db0 add ActorResetFunc for courtyard guards (#1213)
Co-authored-by: briaguya <briaguya@alice>
2022-08-16 21:50:52 -04:00
briaguya 01b7fedc35 clean up a few epochs that were missed (#1204)
Co-authored-by: briaguya <briaguya@alice>
2022-08-16 21:50:37 -04:00
briaguya 71b1db1fb6 volvagia interpolation fix (#1203)
Co-authored-by: briaguya <briaguya@alice>
2022-08-16 21:50:12 -04:00
aMannus b4614acf70 Update Enhancement Presets with new options (#1114) 2022-08-16 22:18:44 +02:00
aMannus cd37a56161 Rando: Fix being able to get Sun's Song check multiple times (#1185) 2022-08-16 22:16:44 +02:00
Josh Bodner eb632ccb50 Adjustable push speed (#1190) 2022-08-16 22:09:11 +02:00
Christopher Leggett 0f2e7db8e0 Fix Ice Traps on Windows and Mac (#1216) 2022-08-16 21:49:52 +02:00
GaryOderNichts a3d0962054 Fix ocarina right stick controls (#1211) 2022-08-16 13:47:41 +02:00
lilDavid 46a421f933 Add window to customize specific controls (#1122) 2022-08-16 09:43:09 +02:00
Zaxus125 b7f9960a60 [cmake] Improve OTRExporter asset extraction script, Lower required CMake to 3.16 (#1196)
* supply ZAPD.out path as an argument to extract_assets.py rather than regenerating the script

Generating an entirely new script file to change a string is excessive.
Instead, extract_assets.py takes in one optional positional argument that
contains the path to ZAPD.out, the original purpose for the string
replacement.

This also removes the need for the file(CHMOD ...) command, which bumps
the minimum cmake version all the way up to 3.19.

Additionally, there was an extra script being generated in
OTRExporter/CMakeLists.txt that used the same CHMOD logic, but did not
accurately declare its minimum version to 3.19, this removes that unused
logic.

* OTRExporter: accept a rom path as an argument to extract_assets.py
2022-08-16 09:34:30 +02:00
th-2021 b46c7a0607 [cmake] Use SDL2, GLEW and GLFW from vcpkg (Windows) (#1194) 2022-08-16 09:29:45 +02:00
briaguya ee9ea3f2bd add 3drando license (#1206)
Co-authored-by: briaguya <briaguya@alice>
2022-08-15 21:17:58 -04:00
briaguya a31256d956 controller menu cleanup (#1166) 2022-08-15 23:02:45 +02:00
Jeff Manian 7a9160ed78 Clarify how to build and run on Mac (#1195) 2022-08-14 23:21:16 -04:00
briaguya 42bce9d33e don't abuse epochs (#1179)
* don't abuse epochs

* update bongo hand trails

Co-authored-by: briaguya <briaguya@alice>
2022-08-14 23:18:12 -04:00
aMannus fabe051d3d Fix lost woods leading music in rando (#1155) 2022-08-14 23:04:40 -04:00
Julien Lemay 8945b2ed48 Fix Save Editor Event Check Inf "A" Row flags (#1138)
Fix Save Editor Event Check Inf Flags "A" Row flags not working. It was set to "eci1" instead of "eci10".
2022-08-14 23:02:14 -04:00
aMannus d575a3dda6 Fixed rotation of freestanding key checks in rando (#1135) 2022-08-14 23:01:30 -04:00
aMannus 37dd045bd2 Rando: Fix bomb/bombchu shops (#1134)
* Fix bomb shops in rando

* Addressed review comments
2022-08-14 23:01:00 -04:00
aMannus 651e0ddad4 Fixed 2 incorrect needs_save instances (#1115) 2022-08-14 22:59:12 -04:00
GaryOderNichts 68e7f2e6c1 Wii U support (#1097)
* Wii U support

* [WiiU] Combined Dockerfile

* [WiiU] Combined Dockerfile

* [WiiU] Combined Dockerfile

* Add Jenkins support

* wiiu: fix scissor clamp

* wiiu: improve button remapping

* wiiu: fix scaling issues

* Update Dockerfile after merge

* Pull assets before build

* Only stop container once

* Adjust logging sinks

* wiiu: Change button mapping to match PC version

* wiiu: Implement controller changes

* wiiu: Update BUILDING.md

Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com>
Co-authored-by: David Chavez <david@dcvz.io>
2022-08-14 22:57:24 -04:00
KiritoDev b989ef4f7f Fixed error screen (#1184) 2022-08-14 12:41:15 -04:00
sholdee 789cf13aae [ci] move asset gen timeout to steps block (#1163) 2022-08-12 18:59:20 +02:00
Kenix3 86faa42acf Make libultra OSContPad struct consistent with the one from libultraship 2022-08-11 19:41:53 -04:00
Kenix3 d623ac5918 Copy over right stick Y axis sensitivity in the UI when the X sensitivity is changed. 2022-08-11 19:41:53 -04:00
Kenix3 4a3e43f73f VirtualController -> DummyController in CMake 2022-08-11 19:41:53 -04:00
Kenix3 094388187f Cleans up Controllers
Renames VirtualController to DummyController.
Makes controller axis treated the same as buttons.
Made Controller class members private or protected
Made Controller class treat deadzones, sensitivities, and press thresholds consistently.
2022-08-11 19:41:53 -04:00
th-2021 791f7774a5 [cmake] Split OTRGui into it's own target (#1116) 2022-08-11 10:05:54 +02:00
sholdee e88000aeb0 [ci] asset stage tweaks (#1120) 2022-08-11 10:05:26 +02:00
Kenix3 d34a6d7666 Fixes error in LUS where there were multiple Vertex classes declared. 2022-08-10 23:14:29 -04:00
Kenix3 3bcc9514ab Cleanup ControlDeck class 2022-08-10 20:21:36 -04:00
Kenix3 15fba97949 Fixes some missed conversions of Console class singleton within the class itself. 2022-08-10 00:38:56 -04:00
Kenix3 6766719969 Fixes issue in Apple builds where imgui was referring directly to Console.Commands 2022-08-10 00:38:56 -04:00
Kenix3 6484d9354d Fixes incorrect command string when adding basic console commands. 2022-08-10 00:38:56 -04:00
Kenix3 23fb885e09 Console class is now a proper object oriented class. 2022-08-10 00:38:56 -04:00
Kenix3 81cd594704 Console now exposes commands with a reference to itself. 2022-08-10 00:38:56 -04:00
Kenix3 797d9fab7c GameOverlay command handler no longer uses SPDLOG and prints to console. 2022-08-10 00:38:56 -04:00
briaguya 96c2033361 fix linux release mode crash (#1124)
Co-authored-by: briaguya <briaguya@alice>
2022-08-09 22:50:25 -04:00
Kenix3 7b11509010 Fixes missed Switch specific invocation of old Console logging macros. 2022-08-09 22:34:16 -04:00
Kenix3 a4804d7290 No longer passing in C strings to SendInfoMessage formatted overload. 2022-08-09 22:34:16 -04:00
Kenix3 5751b5c278 debugconsole now uses console output functions. 2022-08-09 22:34:16 -04:00
Kenix3 f97f9ae422 Sets default value of ConsoleLine channel to "Console" 2022-08-09 22:34:16 -04:00
Kenix3 c7ccd6dbff LUS Cleanup: Strips out the logging system created for the console
Properly routes SPDLog to the console.
Creates an API to be able to send command responses back to the console.
Cleans up the console UI, hiding options when not needed.
Removes stdout console sink for Windows.
2022-08-09 22:34:16 -04:00
Kenix3 1f351418e1 Removes a couple printf in favour of SPDLOG calls. 2022-08-09 22:34:16 -04:00
aMannus e4b58e5a0c TWEAK: Layout/styling overhaul for the F1 menu (#1026)
* First pass of UX changes

* More padding/styling/layout

* More styling

* Moar styling

* Some more styling

* Implemented padding helpers

* More styling, added closing buttons to windows

* Fixed merge conflict mistake

* Fixed new enhancements

* Hopefully fix jenkins errors

* Changed button behaviour, more styling

* Tiny code cleanup

* Change buttons from close/open to > when open

* Small button spacing fix

* Small styling changes after merge

* Small fix after merge mistake
2022-08-09 02:16:45 -04:00
Kenix3 0d9c390526 Removes no longer desired commented code. (#1105) 2022-08-08 21:53:36 -04:00
Kenix3 b924831eba Merge pull request #1104 from briaguya-ai/rachael-to-zhora
rachael -> zhora
2022-08-08 21:53:04 -04:00
briaguya 317de33a8b Merge branch 'develop-rachael' into rachael-to-zhora 2022-08-08 21:43:04 -04:00
briaguya fa090c51f6 Merge pull request #831 from leggettc18/custom-messages
System for Creating and Storing Custom Messages
2022-08-08 21:24:48 -04:00
Christopher Leggett e63d84bd7d Adapts this branch for cmake building. 2022-08-08 21:14:29 -04:00
Kenix3 5581f45050 Adds instructions for Visuals Studio 2019 2022-08-08 21:01:46 -04:00
Josh Bodner b6934b34db Re-add Windows dependencies to build instructions (#1102) 2022-08-08 20:04:55 -04:00
sholdee 5453c68399 [ci] docker improvements (#1101) 2022-08-08 19:59:43 -04:00
aMannus 4ea7f8371f Rando: Zelda sequence fixes (#1095)
* Fixed zelda sequence oddities

* Fixed code inconsistency

* Adressed review comments

* Adressed review comments, removed unneccesary entrance skip

* Addressed some more review comments

* tiny cleanup
2022-08-08 19:59:06 -04:00
th-2021 c803ff65ce fix path to ZAPD (#1092) 2022-08-08 19:58:43 -04:00
InfoManiac742 0e10b59307 Update z_kaleido_item.c (#1046) 2022-08-08 19:58:01 -04:00
InfoManiac742 4bf4ad3359 Update z_en_ru1.c (#1042) 2022-08-08 19:56:56 -04:00
lilDavid f80ba4102a Add instant boomerang recall (#1006) 2022-08-08 19:55:07 -04:00
KiritoDev a4334ecb02 Changed input disable to only be forced on switch (#941)
* Changed input disable to only be forced on switch

* Inverted if

* Finally fixed validation

* Removed enhancement if its a switch build

* Input now only gets blocked when the device is not a keyboard or its on switch

* Input gets blocked when the controller view is opened

* gControlNav is enabled by default on switch

* Fixed compilation issues
2022-08-08 19:53:43 -04:00
aMannus a8fea61bda ADD: Enhancement presets (#926)
* Proof of concept

* Finished default preset

* Added v1 presets

* Overhauled implementation

Function has been moved out of ImGuilmpl.cpp, and all presets have been put in their own functions so they can be applied in a cascading manner.

Also did some slight changes to the presets themselves.

* Fixed link animation settings

* Deleted unneccesary change

* Fixed missing newlines

* Moved functions back to ImGuilmpl.cpp

* Removed Ironman preset
2022-08-08 19:52:34 -04:00
Dog 1f5d323d89 Randomizer: Skip Cutscenes (#846)
* Skip Jabu Jabu's fishy feeding time if rando is enabled Issue #757

Also skip the ganon tower fall cutscene if you died to ganon during the ganon fight for issue #773

* Immediately give control back to player when talon running cutscene starts.

* Fix case of not skipping Gannon
2022-08-08 19:48:53 -04:00
briaguya cf639b1d51 SDL/OpenGL - actually use the window resolution from the json (#1082)
* actually use the window resolution from the json

* switch fix

Co-authored-by: briaguya <briaguya@alice>
2022-08-08 19:46:37 -04:00
Christopher Leggett 59baf24dc6 Merge branch 'develop-zhora' of https://github.com/HarbourMasters/Shipwright into custom-messages 2022-08-08 19:46:09 -04:00
David Chavez 9b33827d02 [ci] Share Generated Assets Across All Platforms (#1074) 2022-08-09 00:02:35 +02:00
David Chavez 9afbe42720 Use -O2 for Release config builds (#1083) 2022-08-08 12:01:45 +02:00
Christopher Leggett 7f233de502 Fixes CMake to explicity launch python interpreter on Windows. (#1089) 2022-08-08 10:31:47 +02:00
th-2021 ed9378375d [cmake] Use static libraries with vcpkg on Windows (#1079) 2022-08-07 18:23:20 +02:00
th-2021 e51e7f3d45 [cmake] Fix Switch icon (#1084)
* Update CMakeLists.txt

* fix switch icon

* Update soh/CMakeLists.txt

* Update soh/CMakeLists.txt

Co-authored-by: David Chavez <david@dcvz.io>
2022-08-07 16:47:16 +02:00
GaryOderNichts cb2410d9c5 Handle audio thread properly 2022-08-06 21:52:42 -04:00
qurious-pixel b2ac01bc98 [CI] Link Updated SDL2 version (#1078) 2022-08-07 03:52:22 +02:00
David Chavez 1794683d3a Ignore build.c 2022-08-06 21:06:40 -04:00
David Chavez c70e3f38b1 Enable SPD logging in libultra 2022-08-06 21:06:40 -04:00
David Chavez aadabe1ecd Better instructions for VS solutions 2022-08-06 21:06:40 -04:00
briaguya 7f58ef14ee add a command to copy the otr to the build dir 2022-08-06 21:06:21 -04:00
briaguya 8efeceb236 formatting 2022-08-06 21:05:51 -04:00
briaguya 9a126dec4e add version requirements in building.md 2022-08-06 21:05:51 -04:00
th-2021 7ef3fff869 add soh icon for Windows (#1060) 2022-08-06 22:19:06 +02:00
th-2021 1ebca42f46 Move to cmake across all platforms (#363) 2022-08-05 07:59:19 +02:00
Kenix3 93d0d7443a LUS Cleanup: Removes GameSettings class. Moves code to Imgui. (#1036)
* LUS Cleanup: Removes GameSettings class. Moves code to Imgui.

* Fixes more strdup problems and finalized removal of GameSetting.

* Reverts changes to Directory.h

* Update Directory.h

* Fixes PR.

* Update Directory.h

* Update rando_main.cpp
2022-08-05 01:03:11 -04:00
Josh Bodner c23457d666 Automatically save after every scene transition (#984)
* Automatically save after every scene transition

* Refactor and don't save in grottos

* Don't save in cutscenes

* Save after getting items as well

* Fix paren
2022-08-05 00:15:49 -04:00
Kenix3 2f5f089e7f Increment version 2022-08-04 17:35:32 -04:00
Kenix3 5f913cb9bf Merge pull request #1037 from briaguya-ai/rachael-to-zhora
Rachael to zhora
2022-08-03 23:18:24 -04:00
briaguya 739434e3e4 Merge branch 'develop-rachael' into rachael-to-zhora 2022-08-03 23:01:11 -04:00
Ada bd86c792c3 Moves release version text (#1028) 2022-08-03 22:44:43 -04:00
Christopher Leggett dffcbb035e Fixes glitchy dungeon maps. (#1032) 2022-08-03 22:43:55 -04:00
Kenix3 97adc4a7f2 Changes string.h include in CVar.cpp 2022-08-03 21:48:51 -04:00
Kenix3 6190388164 Now using posix strdrup on non-msvc builds. 2022-08-03 21:48:51 -04:00
Kenix3 8c9d067657 LUS Cleanup: CVars functions are now consistent 2022-08-03 21:48:51 -04:00
Kenix3 6d3d5e7da5 LUS Cleanup: Removes unnecessary ModManager class. 2022-08-03 21:48:39 -04:00
Kenix3 212d774613 Clean up unnecessary compiler checks. 2022-08-03 21:12:51 -04:00
Kenix3 e68fac14c8 Uses correct audio player per platform now. 2022-08-03 21:12:51 -04:00
Kenix3 7675309e3f Moves specific audio player header file include to after the definition of AudioPlayer class in AudioPlayer.h 2022-08-03 21:12:51 -04:00
Kenix3 4ce19e1448 LUS Cleanup: Only including the correct audio player header file. 2022-08-03 21:12:51 -04:00
Kenix3 fd379896d6 LUS Cleanup: Clean up hooks system. 2022-08-03 21:12:51 -04:00
Kenix3 8431cddb14 LUS Cleanup: GameOverlay and moves various GUI related files to it's own filter. 2022-08-03 20:10:39 -04:00
Kenix3 2d60c772bf LUS Cleanup: Controllers cleanup (#1016) 2022-08-03 00:07:52 -04:00
Garrett Cox 6d0d608e38 Unrestricted warping in randomizer (#951) 2022-08-02 23:51:07 -04:00
Nycz db33604171 added Cheat Sync Time (#957)
* added Cheat Sync Time

This syncs the ingame time with the real world time.
I wasnt quite sure where to put the code so im sorry if this is bad i just wanted to contribute to this project.

* Update soh/src/code/z_play.c

Co-authored-by: Christopher Leggett <chris@leggett.dev>

* Update z_play.c

added suggestions from leggettc18

* Update z_play.c

Co-authored-by: Christopher Leggett <chris@leggett.dev>
2022-08-02 23:48:41 -04:00
InfoManiac742 27e0f19dac Remember save location (#980)
* Remember save location

* Clarified grotto caveat

* Update ImGuiImpl.cpp
2022-08-02 23:47:57 -04:00
Kenix3 7267b60a26 gfxFramebuffer is now only compared or set to 0 rather than NULL 2022-08-02 23:31:50 -04:00
Kenix3 67d5ba08ab Converts gfxFramebuffer to be a pointer. 2022-08-02 23:31:50 -04:00
Kenix3 1de525900d Removes unnecessary Environment.cpp file. 2022-08-02 23:31:50 -04:00
Kenix3 352b46c1f5 LUS Cleanup: Console class is now in the Ship namespace 2022-08-02 22:54:38 -04:00
Kenix3 1bf7771981 LUS Cleanup: Utils.cpp is now in namespace Ship. 2022-08-02 22:38:01 -04:00
Kenix3 c1659d3dcf Adds a function for grabbing physical device from virtual slot. 2022-08-02 22:37:42 -04:00
Kenix3 b3c3882b12 LUS Cleanup: Make ControlDeck a member of Window 2022-08-02 22:37:42 -04:00
Christopher Leggett d80742d882 Adds documentation comments to CustomMessageManager.h 2022-08-02 19:32:59 -04:00
Christopher Leggett a007bfd14a Merge changes from develop-zhora 2022-08-02 19:17:08 -04:00
David Chavez d9443d98f0 Store RGBA Cvar as JSON object (#996)
* Store RGBA Cvar as JSON object

* Use existing split string method

* Extract key setting to var
2022-08-02 18:09:33 -04:00
aMannus 85c4cd3863 Re-added ImStrdup around string value (#1009) 2022-08-02 23:47:39 +02:00
David Chavez cec0bc6fca Merge pull request #999 from dcvz/rachael-zhora
Rachael -> Zhora
2022-08-02 20:15:26 +02:00
David Chavez 53229f0905 Merge branch 'develop-rachael' into rachael-zhora
# Conflicts:
#	libultraship/libultraship/ImGuiImpl.cpp
2022-08-02 20:05:40 +02:00
David Chavez 61c68666d6 Closer align Makefiles & Dockerfiles (#748) 2022-08-02 16:22:20 +02:00
Christopher Leggett bb8152b376 Replaces string literal for BaseGameOverrides with const variable. 2022-08-01 23:16:16 -04:00
Christopher Leggett 480053dfaa Exposes FormatCustomMessage and uses it in FormatJsonHintText. 2022-08-01 23:05:29 -04:00
Christopher Leggett eae97cff79 Addresses most of bria's comments. 2022-08-01 21:44:28 -04:00
Christopher Leggett 4d30cc50a1 Adds newlines to the ends of some files. 2022-08-01 21:21:29 -04:00
David Chavez 4ed82c71dc Fix c++20 clang issue 2022-08-01 17:16:03 -04:00
Garrett Cox 9389ceb8c1 Speed up lifting silver rocks and obelisks by 5x (#953)
* Speed up lifting silver rocks and obelisks by 3x

* Increase rock lifting speed to 5x

* Fix bug that sped up picking up small rocks, grass, bombflowers

* Add enhancement checkbox for faster block lifting and reduced speed to 3x
2022-07-31 22:09:30 -04:00
Kenix3 4f29833476 Adds beta quest Gameshark cheat. (#975)
* Adds beta quest Gameshark cheat.

* Fixes issue where lus was including a function from soh.

* Limits beta quest to 0-8
2022-07-31 21:52:10 -04:00
Garrett Cox d648c7275c Hide Dpad in minimal UI (#955) 2022-07-31 21:51:36 -04:00
KiritoDev a1ed35e5bd Fixed slowdown on dodongo (#945)
* Fixed slowdown on dodongo

* Invalidate only works on pc

* Added todo comment
2022-07-31 21:49:54 -04:00
InfoManiac742 206f63f9e6 Fix build link in README (#944)
Currently leads to a 404 page since there's no longer a branch called "develop", I've just sent it to the main page for the builds site
2022-07-31 21:48:43 -04:00
Josh Bodner 7a45380123 Automatically break long tooltip lines (#925)
* Remove manual newlines from the middle of sentences in tooltips and automatically break long lines instead

* Move split functionality into header so randomizer tooltips can use it

* Rewrite logic to be O(n)

* Found another typo

* Move helper function to libultraship to (hopefully) get Jenkins happy

* Fix typo I made when fixing the typo before

* Remove unneeded header

* Parameterize line length in case variable line length is desired in the future
2022-07-31 21:40:26 -04:00
GaryOderNichts 99ecccfaab Save scarecrow songs as OcarinaNotes (#918) 2022-07-31 21:39:24 -04:00
PurpleHato 7dd6f59b8b TWEAK: added 360hz support (#896)
* FIX: Increased the maximum actor limit for draw distance

Fix issue #529

* TWEAK: added 360hz support

Has been asked by an user who have a fancy 360hz laptop refresh rate
https://www.androidauthority.com/asus-rog-ces-2021-1191928/

* TWEAK: Forgot one value
2022-07-31 21:38:40 -04:00
vaguerant 361a986b8e Add bottle swipes to Fast Drops; rename to Skip Pickup Messages (#847)
* Add bottle-swipes to Fast Drops; rename to Fast Pickups

* More freecam friendly

* Resolve freecam interaction

* Rename to "Skip Pickup Messages"
2022-07-31 21:37:47 -04:00
Sarge-117 b98c8b4abb Minor enhancement: Allow toggling on equipment screen (#813)
* Allow Equipment Toggle

Allow player to toggle equipment on/off on the equipment subscreen.  For tunics and boots, this will revert them to Kokiri Tunic/Kokiri Boots.  For shields, it will un-equip the shield entirely.  For swords, only BGS/Giant's Knife is affected, and it will revert to Master Sword.

* Set up Cvar and check for MS

Set up the cvar/imgui and add a check that we own the Master Sword (in case we're in the Ganon fight)
2022-07-31 21:35:05 -04:00
David Chavez 582f084973 Use tex sizes from texture rather than hardcoded values (#610)
* Use tex sizes from texture rather than hardcoded values

* Dynamic do action tex sizes

* Remove unused minimap texture keys

* Restore MESSAGE_STATIC_TEX_SIZE

* Use dynamic offsets

* MACRO it up

* Enable SPDLOG in Xcode

* Handle non-existent texture
2022-07-31 21:32:40 -04:00
Christopher Leggett 2f9874c68f Cleanup. 2022-07-31 19:31:22 -04:00
Nicholas Estelami 47ad3bdc47 Fixed linux compile issue 2022-07-31 16:57:04 -04:00
Nicholas Estelami 9d12813282 Fixed merge/rebase issues 2022-07-31 16:57:04 -04:00
Nicholas Estelami 3bb234e6a6 Fixed merge issues. 2022-07-31 16:57:04 -04:00
Nicholas Estelami 44bf5af33a Fixed up merge issues and crash 2022-07-31 16:57:04 -04:00
Nicholas Estelami 0193489b00 RGBA8 CVar Support Added 2022-07-31 16:57:04 -04:00
Nicholas Estelami a6092c21d4 Merge with develop 2022-07-31 16:57:04 -04:00
aMannus fa0a66695c Skips time travel cutscene in rando (#956) 2022-07-27 22:18:27 -04:00
GaryOderNichts 6818247317 Big-endian support (#909) 2022-07-27 23:50:56 +02:00
Christopher Leggett e8d2b0cceb Hopefully fixes build errors on Linux-CI. 2022-07-26 20:46:49 -04:00
Christopher Leggett 5a97e9f0de Factors away some raw textIDs into an enum with descriptive names. 2022-07-26 20:11:17 -04:00
Christopher Leggett d0968a99c1 Removes some unneeded function definitions (some of which were already commented out). 2022-07-26 19:25:17 -04:00
Christopher Leggett 0ed8c277e8 Renames some variables for clarity 2022-07-26 19:07:54 -04:00
PurpleHato 477cf7f6ec ADD: Rando Spiritual Stones Power (#910)
* ADD: Try to use Spiritual Stone alpha on altar

Not super advanced but it kinda work, n eeds to figure out why the gSaveContext.inventory.questItems doesn't seems to care

* TWEAK: Full working + added on child link side

* TWEAK: added else with comment

* frogot a }
2022-07-26 18:46:02 -04:00
Christopher Leggett 59dc52f394 Moves the NOGDI define to CustomMessageManager.h 2022-07-26 18:44:52 -04:00
Christopher Leggett 822476373b Renames CustomMessage to CustomMessageManager 2022-07-25 22:33:38 -04:00
Christopher Leggett 4c9e4b2d84 Puts CustomMessage files in filters in Visual Studio 2022-07-25 22:04:53 -04:00
Christopher Leggett 2ff5d54592 Merge in develop-zhora 2022-07-25 21:33:19 -04:00
Christopher Leggett cd01e8b778 Moves deku scrub messages into CustomMessageTable. 2022-07-25 21:31:17 -04:00
David Chavez 8bdc4458c7 Improve string split performance (#933) 2022-07-25 21:12:25 -04:00
KiritoDev 5f718932e6 Nintendo switch support (#935)
* Moved gfx effects to the gpu and removed loadtexbyname on some textures

* Readded empty if

* Added nintendo switch support

* Fixed compilation errors and window closing issue on linux

* Fixed kaleido on 64 bit

* Fixed audio on nintendo switch

* Implemented performance mode switcher

* Added suggestions from pr review

* Fixed ftruncate errors

* Fixed compilation errors

* Added missing include rule

* Fixed libstorm path

* Removed ftruncate extern to use a correct posix version

* Merge branch 'develop' from HarbourMasters into znx (#3)

* Add Support for macOS (#441)

* Fixed soh filters

* add more makefile changes

* almost ready

* more updates

* update

* update

* Update Makefiles to handle both platforms

* Allow for overriding the CXX and CC executables

* Restore original structure while supporting custom CXX flags

* Remove some platform specific libs

* Dynamic target name

* Make X11 paths package-agnostic

* Remove changes to `gfx_opengl.cpp`

* Use OpenGL2 on MacOS instead of OpenGL3

* make it actually render something

* render at least the first texture, still need to figure out the second
one

* Let’s use OpenGL 3 again

* maybe this works to get the right texture? link's eyes still look off a bit

* did this work?

* set the platform to macos

* actual numbers are right, but logic is ugly XXX/TODO, i know

* add zlib to ldflags for ZAPDUtils

* A bit of cleanup

* Revert unneeded changes

* Remove GL_CHECK

* Fix issues with z64 branch

* use an std::map instead of a giant array

* three point filter fix (#2)

* Fix mac compilation

* fix audio for 64 bit

* revert audio heap size, keep bigger pools

* Add more Apple specific checks to our modifications

* Add building instructions for macOS

* Remove unecessary step from building instructions

* Add missing SDL2 & GLEW to Linux LDLIBS

* Update BUILDING.md

Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Update soh/.gitignore to include other arch binaries

Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Use right platform name for debugging window

Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Fix stormlib on macos (arm64)

* Simplify some of the ifdef checks

* Revert an older no longer necessary fix

* Remove remaining unecessary deviations

* Update building instructions after StormLib changes

* Feature: Use OpenGL 4.1 (#1)

* Further tweak the BUILDING

* Tidy up

* reword -j message

* Add Jenkins CI Support (#2)

* Fix type issues

* add target <appbundle> and <filledappbundle>

add makefile targets to create an .app
`filledappbundle` creates the target with the .otr included

this should perhaps be moved to Application Support though

* pull gcc's rpath from otool output

* move make target to the end so it's not default

* Add Jenkins and make exe in par with other platforms

* Actually save build artefacts

* Fix artefact path

* Remove x11 mentions and linking (not used)

* Update building instructions for generating app

* use appsupport directory

* Add new app icon

* Update target to match macOS types

* Update more audio types

* fix null deref in Audio_PlayFanfare

* Remove old import from z64

* address final nit with apple ifdefs

Co-authored-by: KiritoDev <36680385+KiritoDv@users.noreply.github.com>
Co-authored-by: Jeffrey Crowell <github@crowell.biz>
Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Move macOS to parallel stage

* fix linux crash

* Ignore all named saves

Necessary after new save format

* DPad items

* Move UI location arrays from static to global to accomodate customizable UI

* FIX: Increased the maximum actor limit for draw distance

Fix issue #529

* FIX: Remove duplicates of gNewDrops from the enhancements menu

* Get rid of erroneous int casts

* casts jya_cobra's shadowTexture pointer to uintptr_t instead of s32.

* Fix ability to assign equipment you don't own

* Fix title cards for market potion shop and bombchu shop

* Invalidate message item icon texture before drawing

* Add margins for dpad

* Fixed some instances where the original OOT save is erroneously preserved or recreated, leading to another conversion next time you launched the game

* Headphones setting in game should now work.
Resolves #13

* Map Select name fixes

* Change Power to Upgrades

* Rename Soh* files

* Update names

* Add more files

* Add more files

* Add toggles for disabling heart drops and random drops (#507)

* Adds toggles for disabling random drops and fixed heart drops

* Changed the "No Fixed Heart Drops" toggle to the more useful "No Random Heart Drops" toggle

* Adds an explanation that the no heart drops option is similar to Hero Mode

* Moved difficulty options into their own sub-menu
Moved time saver options into their own sub-menu
Moved clutter reducing options into their own sub-menu

* fixed the tag name of mweep speed

* Moved Skip Text to Experimental

* Fix testing masks of DPad

* Fix audio, boot commands, and save staes.

* add menu from https://github.com/PurpleHato/Shipwright/tree/ResetMenu

* implement reset

* Update README.md

* command on mac

* special char doesn't work with default imgui font

* change name based on PR comment

* missed a couple spots

* change sunset in save editor so dampe is out

* Update to latest `docking` imgui (#582)

* Update to latest `docking` imgui

commit: 67410d53f739b6a0df138e2252f0e5136b42062f

* Fix modified import for SDL

* Update imgui_impl_sdl.cpp

* Add Imgui include path for better imports

* Controller Navigation Fix-Up (#544)

* Controller Navigation Fix-Up

* [MISC] Fix typo

* Use Macro for __FILE__ & __LINE__ when possible (#559)

* First batch some overlay

* Almost all overlay

* effect & gamestate

* kaleido stuffs

* more overlay

* more left over from code folder

* remaining hardcoded line and file

* Open & Close _DISP __FILE__ & __LINE__ clean up

* Some if (1) {} remove

* LOG_xxxx __FILE__ , __LINE__ cleaned

* ASSERT macro __FILE__ __LINE__

* mtx without line/file in functions

* " if (1) {} " & "if (0) {}" and tab/white place

* LogUtils as macro

* GameState_, GameAlloc_, SystemArena_ & ZeldaArena_

* Revert "GameState_, GameAlloc_, SystemArena_ & ZeldaArena_"

This reverts commit 0d85caaf7e.

* Like last commit but as macro

* Fix matrix not using macros

* use function not macro

* DebugArena_* functions
GameAlloc_MallocDebug
BgCheck_PosErrorCheck as macros
removed issues with ; in macro file

* MM Bunny Hood enhancements: no age restrictions & wear across entrances (#560)

* Remove age restriction on MM Bunny Hood

* Handle mask slot changing; init Link wearing mask

* Reset mask state after selling

* Use unordered maps in some hot paths (#566)

* Use unordered maps in some hot paths

* Address PR comments

* Cheat: Infinite Epona Boost (#577)

* Cheat: Infinite Epona Boost

* Edit for readability

* update pulseaudio for 44.1khz audio (#587)

* use pulseaudio defaults

* spaces/tabs

* pulseaudio values tuned for n64 audio at 44.1khz

* update tlength

* remove one hardcoded samplerate

Co-authored-by: briaguya <briaguya@alice>

* Restoration Item Sliders (#595)

* Allows players to set custom restoration values for potions and milk

* Fixed a dumb oversight

* implemented fairy sliders

* use ini window resolution (#410)

* use ini window resolution

* use arguments for directx window size

* default 640x480 not 320x240

* kick off a build

* and revert

* default config 640x480 not 320x240

* add todo

Co-authored-by: briaguya <briaguya@alice>

* 3D Drops & Projectiles update (#548)

* Fix remaining rupee and keys

* fix tabs -> spaces

* more fix about tabs -> spaces

* Better up <-> down mouvement for hearts

* remove useless comment

* Cosmetics menu rework (#589)

* -

* DPad/some margin fix(left side)

* various ImGui stuff and fixes

* disabled kaleido menu (non working)

* fix win being dumb

* same for C btn this time

* Fix windows build

* Beating hearts fix

* Default win size and some placement fix

* Fix Dpad Ammo & C notes, Kaleido, white dog

* some texts fix and tab move

* Add stone of agony, some fixes and build correctly

* precise item place with Dpad

* Gamecube -> GameCube

Co-authored-by: Baoulettes <iMacWin10>

* [CI] Create an Appimage for 64bit builds (#570)

* [CI] Create AppImage file

* [CI] Updated Jenkinsfile

* [MISC] fix indentation

* [MISC] Fix indentation

* [MISC] Fix indentation

* [CI] 7z appimage and readme

* [CI] AppImage icon file (#597)

* [CI] Add patchelf

* [BUILD] Include Hi-Res icon

* Fix portability use of std::clamp (#596)

* Add N64 weird frames and OOB Bombchus cvars (#602)

* Add gN64WeirdFrames and gBombchuOOB cvars

* Rename gBombchuOOB to gBombchusOOB

* Fix pipeline

* [BUILD] Do not strip ZAPD (#598)

* [BUILD] Do not strip ZAPD

* [BUILD] Reuse Icon Asset

* [APPIMAGE] Handle paths with spaces

* [macos] Distribute optimized builds (#599)

* Cosmetics texts fixes (#604)

* branch init + few fixes

* Reset button

* Several texts fixes and default color to GameCube

* space issues

* some more extra space that was not needed.

* space yes last time ...

* Arrows being able to be rainbow some more texts fixes

* more texts fixes

* c-buttons some plurial fix

* Fixes bug in demo effect due to removed display list set.

* King dodongo room crash (#613)

* first attempt

* force camera setting to be at least 0 (dirty!)

* -

* reverted something to just include fix

* Invalidate text box icon before drawing (#607)

* [APPIMAGE] Set lib path for ZAPD (#611)

* New drop runtime fix (#614)

* inital rework

* fixed default rotation for 2D sprites

* fix tab/space issues

* Fix Ganon's Castle title cards (#606)

* Checkered room crash workaround (#615)

* Increase poly and vertex count for dyna actors

* Add TODO

* Only apply fix in Forest Temple

* Enable globally

* Match case of 'Shipwright' in Linux build (#619)

* Fix 0xabababab crash (#617)

* Unconditionally setup the normal skybox

* Only call Skybox_Setup once ever

* Equipment upgrade text fix and any pause slot enhancement fix (#620)

* Fix upgrade name text not rendering

* Use cvar and don't render equip help for empty item slots

* Fix rendering logic

* Fix incorrect item name rendered for one frame

* Reorder comparison

* Remove extra indent

* Remove accidental changes

* ImGui grammer, consistency, and clarity fixes (#625)

* ImGui grammer, consistency, and clarity fixes

Co-Authored-By: Stormghetti <56653191+Stormghetti@users.noreply.github.com>

* Adds more new lines for users on smaller displays

Co-Authored-By: Stormghetti <56653191+Stormghetti@users.noreply.github.com>

Co-authored-by: Stormghetti <56653191+Stormghetti@users.noreply.github.com>

* New drops shadows & rotation fixes (#627)

* fixes

* forgot to add heart pieces in rotation logic

* Dodongo's Cavern blue warp crash fix (#622)

* Doodong's Cavern blue warp crash fix

* >= not >

* Don't waste a line of space

* add support for clang compiler (#592)

* hacks to align strings for clang... wow just wow

* start work to getting built with clang

* fix issues with struct constructors, all builds, doesn't link still

* fix some narrowing issues that clang complains about

* fix compliation of zapd

* fix null deref in VersionInfo

* builds with clang

* make stringbuilding use StringHelper instead of addition

* fix linking

* add CLANG SHIP overlay on clang built versions

* doesn't need to be volatile

* mark unknown strings as extern

* rename some stuff

* can't align extern

* hopefully fix compilation for everythign

* expandtab

* allow setting LD

* Revert "allow setting LD"

This reverts commit 711aba6db2.

maybe to use lld it should be a LDFLAG?

* -Wno-deprecated-declarations is required for newer versions of clang

on macOS 13 beta sdk, the version of apple clang requires this

* Add jenkins support for clang

* Forward CXX flags to stormlib compilation

* Move GCC only flags to check

* use exports to set multiarch setup

* Fix Jenkins forever

* use make instead of cmake --build

add some flags to build with clang-11 as well

* address review coments

- rework extraction to allow multi thread
- misc readability cleanup

* update makefile to add WARN on linux+clang

Co-authored-by: David Chavez <david@dcvz.io>

* Fix develop

* Fixes grey screen issue + tooltip for 2 handed shield

* Don't close controller after SDL has quit (#642)

* Don't close controller after SDL has quit

* Don't check if controller can rumble if null

* Fixes Barinade's set whenever boss fight is reloaded (#639)

* Reimplements unused Barinade reset function.

* Removes the Jellyfish from Barinade's body on reset.

* add the ability to pull graves during the day (#637)

* change max internal res multiplier to 3x, use float and % instead of int (#638)

* change max internal res multiplier to 3x, use float and % instead of int

* Update libultraship/libultraship/ImGuiImpl.cpp

Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>

* Fixes crash on Biggoron trade failure screen wipe

Resolves #621

* fixes center docking (#652)

* testing out item replacement (#416)

* skip learning song of storms

* don't set flag when getting goron tunic as child

* Initiates prelude check when master sword unloads.

Not quite how N64 rando does it but so far it's the only way I've found to make it trigger without also triggering the time travel again.

* Stops Shadow Temple lore prompts from appearing in rando.

* Skips cutscene of royal tomb explosion in rando.

Explosion sound doesn't play correctly and I think the debris appears in the wrong place, but the functionality is here.

* Improves visual of exploding gravestone.

* Adds some comments explaining the rando differences

* Skip ruto text box in jabu blue warp

For rando

* skip intro cutscene in dodongo's cavern

* load spoiler files on boot, fix spoilerfile existing check when making new saves

* name entry dropped spoiler logic

* make sure to actually init the cvar

* no chime on load

* uncomment

* Skip ganondrof cutscene

Skip to scream part of the death animation, skipping the text boxes etc. For rando

* Update z_boss_ganondrof.c

* skip owl flight cutscenes in rando

* Fixes skipped text so it only applies to shadow temple.

Earlier fix inadvertently applied to some other text as well, changed logic so that only specified sceneNums and textIds can have this enabled, and text skipped by sceneNum can have the skip overriden by textId if needed. Currently there are no overrides so the textId section of the logic is commented out to avoid compilation errors.

* Adds a default to the switch case statements that leaves the randoSkipText variable unchanged, just in case.

* TEST: Text for item

* Adding ganon flavor text

* ADD: AMMO Count

* format ganon text/hint text

* Autoskip the tower cutscene if settings call for tower collapse.

* ganon hint text logic

* Improved prelude after time travel fix

* swapped the sizes between ganon hint text and ganon text, as they were set to the wrong things.

* this is all i did

* not the cleanest code ever but it's working

* ADD: GS Count

* ADD: Wallter (crash for now)

* TWEAK: Wallet check

* FIX: Use DrawItem instread of DrawUpgrade... b-baka!

* Fixes some vanilla bugs introduced by rando code.

* Added cutscene skip for zelda escaping

Using the debug cutscene skipping function. Also added a conditional so the bridge doesn't spawn closed when cutscene is ready to trigger

* ADD: X Spacing + Placeholders for song

* ADD: default case for items

* TWEAK: Spacing

* FIX: Light Arrow

* ADD: Ammo Option

* use groups instead

* ADD: More spacing logic

* songs and names

* TWEAK: Color on wallet

* colors

* Added flags cutscene before nabooru fight

* ADD: ChromaKey text

* First attempt skip cs after nabooru defeat

* Better implementation for specific rando cutscene skips

* use pulseaudio defaults

* spaces/tabs

* move color push/pop to stop crash

* make the colors work again

* the real bottle fix

* pulseaudio values tuned for n64 audio at 44.1khz

* update tlength

* remove one hardcoded samplerate

* Cleaned up and fixed zelda escape skip

The if statement is a freaking monster, but unless we want to skip more cutscenes in the same way later, this is the most compact way of doing it that I know of.

* Revert one line to match original

nothing functional

* another hint line that breaks autonewline logic

* don't autospawn epona if we don't have the song/ocarina

* Trying to use iron knuckle death effects

not working yet

* Streamlined OoT cutscene skip for future additions

Also cleaned up if statement in general

* Made if statement more readable

Also added clarity for what cutscene was skipped

* Fixed typo in comment

* Janky nabooru defeat cs skip

* altar text formatting (gonna need help shortening some of the french ones)

* more altar text formatting

* english altar text formatting complete

* make gtg blocking guard check for card not bridge

* FIX: Typo!

* FIX: Uppercases

* FIX: Typo

* TWEAK: Alter + some names

* TWEAK: More caps!

* ADD: Missing string

TWEAK more uppercases and namefixe
s

* Hide nabooru death by covering her in flames

* bandaid fix for death crash issue

* Twinrova defeat cs skip

Skips the animation and manually calls the function to show the "beam" around the sisters

* fix crash

* fix caps to match

* fix great fairy reward mashing/shielding issue

* TWEAK : Typo clé to Clé

* TWEAK: Some Altar hints

TWEAK: Some capitals

* TWEAK: Unmatching text + some cap again

* TWEAK: More tweaks

* fix build

* remove extra json.hpp, add hint

* Update randomizer_item_tracker.cpp

* TWEAK: Double Defense with RedParticles instead of white

* make sure we don't optimize out the check to ensure a spoilerfile exists

* vanilla ganon boss key hint formatting

* TWEAK: FR- better way of the hero text

* fix

* and again

* Initializes dungeonsDone items in gSaveContext to 0.

* Replaces sizeof calculation with a NUM_DUNGEONS constant.

* Fixes Saria's Gift on the LW Bridge from getting killed when holding shield.

* More airtight fix for Saria's Gift on the Bridge.

* Lifts one of the conditions in the if statement a little higher to prevent unnecessary lookups of getItemId.

* Invalidate text box icon before drawing

* Fixes the case where Saria's gift is an Ice Trap.

We still get the Ice Trap once, but never again. This does mean you can now hold R while walking in to avoid the ice trap, but everything else seems to work fine.

* Initial commit

Might need changing when we change the settings in the future

* Fixes Door of Time opening cutscene after warping with prelude.

* Initial waterfall skip

Very rudimentary way of doing things but it seems to work so 🤷

* inital rework

* fixed default rotation for 2D sprites

* fix tab/space issues

* 3d drops rando merge fix again

* Allows Impa to appear in the Lullaby check post drawbridge escape.

* Changes Ganon's Trials Count setting to a checkbox

The checkbox is whether or not to skip all of them. Leaving the box unchecked will mean doing all of them. Eventually this will be switched back to a slider once we implement the logic for which trials start out completed.

* Sets all Ganon's Trials to incomplete in new saves.

Fixes https://github.com/briaguya-ai/rando-issue-tracker/issues/131

* fix castle guards when oot throw cutscene has already played in rando

* Properly removes the beams when trials are cleared.

* Removes Question Mark from Skip Ganon's Trials UI.

* Adds a todo comment about when to change back to slider.

* make deku seeds check for bullet bag

* Various tweaks

TWEAK: Altar Text
TWEAK: Hint names
TWEAK: Replace more problematic œ to oe

* upgrade ocarina on both child and adult equips

* FIX: Jabu Item

* update equipped hookshot/longshot when obtained as other age

* add hint

* don't give the bgs check without the claim check

* Skips Darunia Cutscene in Fire Temple

* Added a TODO note about not skipping the cutscene.

There is a setting we will want to have eventually that will require this cutscene to not be skipped since it is used during a glitch.

* remove todo

* restore fast ocarina option in imgui that was lost in merge

* Fixes grey screen issue + tooltip for 2 handed shield

* update to use dg instead of g for textures in item tracker

* TWEAK: Default color for cosmetic RAND button was not the corect one

* fix texture crash, remove unused item tracker code

* don't open mask shop until we get zelda's letter

* Update README.md

* Prevents "correct" chime under incorrect conditions.

* Fixes typo in conditional and adds "bonk" sound effect.

"Bonk" sound is NA_SE_SY_OCARINA_ERROR and it plays when conditions for the Door of Time have not been met after playing Song of Time. This is only possible in rando's "Intended" Door of Time option, in which the Ocarina of Time and all 3 spritual stones are required to open the door, instead of the vanilla requirements of just having the song of time.

* remove modify dpad equips toggle, replace with checks for dpad menu

* remove extra check

* add ability to hold c-up to assign to dpad when dpad menuing is enabled

* disable d-pad navigation on item menu when holding c-up to equip

* dpad+c-up stuff for equipment menu

* ADD: Checbox for songs colors

* TWEAK: RandoColors for normal songs

* kind of quick and dirty but it works

* TWEAK: Clarity of the tooltip

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Dog <5172592+Dog@users.noreply.github.com>
Co-authored-by: Vague Rant <vaguerant@users.noreply.github.com>
Co-authored-by: Baoulettes <perlouzerie@hotmail.fr>
Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>

* Cosmetics hotfixes (#640)

* Initial branch creation

* Revert Main Game so it do not conflict later

* should fix window build, made namespace for Cosmetics

* forgot to edit one title

* Ability to add hidden window (usefull for Rainbow)
Fix building issues

* Line break, unused bool remove

* add descriptive todo for death crash bandaid (#655)

Co-authored-by: briaguya <briaguya@alice>

* Removed legacy audio mode and fixed ganon sound bug (#657)

* Free Camera (#337)

* wip free cam

* Almost done, needs collision still

* Added free cam behind cvar

* added WIP collision

* Fixed & implemented "Manual mode" from WW & TP

* Fixed camera not rotating when Link is moving

* fixed initialized camera rotation

* Fixed camera getting stuck + made it smoother

* reduced deadzone

* fixed epona camera height + added WW z-target free camera

* Adjusted player camera height & fixed fov

* Fixed camera roll

* fixed fov when moving the camera while in z-target

* Camera resets to Auto when going through doors or changing maps

* Fixed building

* touch

* more touch work

* Added WIP mouse support to the free cam

* gui stuff

* fixed building

* fixed building error

* ok fixed building for real this time

* oops

* Fix compilation issues

* removed mouse stuff that magically appeared in this branch

* smoothed out stick values & removed remains of mouse support

* re-added manual camera when pressing Z

* reduced minimum Y position of camera

* Addressed dcsv's nitpicks

* part 2

* oops

Co-authored-by: David Chavez <david@dcvz.io>

* Rando: Allows Malon's Item Check to be obtained by pulling out the Ocarina. [FIXED PR] (#672)

* Fixes using the Ocarina to get the check from Malon.

Still some cleanup to do here. For some reason the player can shield before receiving the check. It doesn't set the flag if the player does that so they can still try again, but would prefer a different solution if possible.

* Prevents Shielding from blocking the Item_Give from happening.

* Code Cleanup and comments explaining the new rando flow.

* Removes inventory check when pulling out Ocarina

This allows OI to properly give the check, which is important for Glitched logic later down the line. Talking to Malon still requires the Ocarina in your inventory.

* Prevents non-malon textboxes from triggering the check.

Also adds a comment explaining the condtional for getting the check from talking to Malon since it got pretty long.

* Actually fixes checking for text boxes.

* Relocates a comment for improved clarity.

* Fix Rando Water Temple Softlock (#665)

We use 3DS logic to generate item placement, but didn't have this specific door in Water Temple unlocked from the beginning like 3DS does.

This meant that if people took specific paths through the temple, they could softlock themselves by missing a key.

* Rando: GtG and carpenter prompts skip (#663)

* Skip gtg and carpenter prompt

For rando. Tested and just works.

* Fixed missing break

* Hide debug overlay behind gDebugEnabled (#660)

* Introduce App Directory Path (#572)

* Introduce app directory path concept

* macos: Remove hacky way of using applicaiton directory

* Update the new SaveManager

* Address stack user after return

* Remove unecessary property

* Use std::string for filepath

* Improve clang specific detections

* Use new path system for imgui files

* Improve helper for getting relative paths

* fix hidden wnd (#744)

* Split damage multiplication into its own PR (#656)

* Split damage multiplication into its own PR

* Found a more elegant implementation of the powers char*[]

* Fixes Maps, Compasses, and Boss Keys in Vanilla. (#751)

* .xiF slebaL

* Update Keese labels

* Fixed soundfont issues

* Skip warp song cutscenes in rando (#664)

Does it by skipping to the last part of the cutscene data. Tested on all songs, both adult and child.

* don't spawn blocking mido after we've already shown him the sword/shield (#675)

Co-authored-by: briaguya <briaguya@alice>

* Controller Configuration UI and JSON Config (#760)

* Initial controller hud ui

* Reverted fbdemo changes

* Moved config to json and implemented controller config

* fix build on linux, gitignore new config file

* fix build

* Fix compilation and file directory paths

* Call save on cvar save

* Fixed cvar loading and added deck slots to the config

* Changed control deck port 0 to use a physical device by default

* Added gyro and rumble & fixed loading errors

* Save config on toggle menubar

* fix linux build

* Fixed drift calculation

* Controller config now saves when pressing F1

* Removed ExitGame hook from ImGuiImpl

* Moved mappings to a map

* Added GetKeyName

* untranslate scancodes

* Fixed hud layout on keyboard device

* Fixed keyboard read on hud

* Fixed crash when reloading controllers

* Removed ConfigFile and changed file extension

* Changed Dummy to Disconnected and fixed filters

* Removed function leftover

* Changed ControllerHud to InputEditor

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: David Chavez <david@dcvz.io>

* Enough! My ship sails in the morning.

* Fixed menubar items position (#763)

* Fixed menubar items position

* Reverted tooltip tab position

* Fixes macOS randomizer functionality with App Directory (#761)

* Fixes macOS randomizer functionality with App Directory

* Fix windows build

* Update soh/soh/Enhancements/randomizer/3drando/rando_main.cpp

* Update soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp

* Revert band-aid fix

Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>

* Fix migration cvar deletion path (#765)

* Various controller fixes (#771)

* Fix controller

* Also fix rumble strength being a bool

* Remove ControllerHud.cpp

* Downgrade platform toolset back to previous version

* Fix gyro

* Fix bug that makes binding axes difficult and clear buttons before reading

* Exaggerate gyro display and adjust stick binding threshold

* Initialize drift thresholds

* git subrepo push soh

subrepo:
  subdir:   "soh"
  merged:   "75ccbade8"
upstream:
  origin:   "https://github.com/HarbourMasters/soh.git"
  branch:   "master"
  commit:   "75ccbade8"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"

* One more change from PR review

* Fix some paths

* Fix merge conflict messup

* More merge conflict fixes

* And another conflict fix

* And another fix

* Remove reference to removed build files

* Add full path to switch cmake

Co-authored-by: David Chavez <david@dcvz.io>
Co-authored-by: KiritoDev <36680385+KiritoDv@users.noreply.github.com>
Co-authored-by: Jeffrey Crowell <github@crowell.biz>
Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>
Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com>
Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: rozlette <Rozelette@users.noreply.github.com>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
Co-authored-by: vaguerant <vaguerant@users.noreply.github.com>
Co-authored-by: earthcrafterman <banddstudios@gmail.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com>
Co-authored-by: Baoulettes <perlouzerie@hotmail.fr>
Co-authored-by: Sirius902 <10891979+Sirius902@users.noreply.github.com>
Co-authored-by: modestposer <modestposer@gmail.com>
Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>
Co-authored-by: Stormghetti <56653191+Stormghetti@users.noreply.github.com>
Co-authored-by: Sirius902 <3645979-Sirius902@users.noreply.gitlab.com>
Co-authored-by: MelonSpeedruns <melonspeedruns@outlook.com>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: Dog <5172592+Dog@users.noreply.github.com>
Co-authored-by: Nicholas Estelami <NEstelami@users.noreply.github.com>
Co-authored-by: ChristopherJTrent <ChristopherJTrent@outlook.com>
Co-authored-by: agamache <aaroncgamache@gmail.com>
Co-authored-by: M4xw <m4x@m4xw.net>

* Fixed switch compilation

* Fixed responsive on switch imgui

* Remove config save hook

* Added physical slots into controller name

* Add `ifdef` for switch specific code

* Add `ifdef` for switch specific code

* Added applet mode detection

* Replaced homebrew icon

* Fixed randomness on applet mode view

* Fixed clkrst initialization

* Switch profiles cleanup

* Cleaned code based on dcvz comments

* Remove unused hooks in Mercury

* Fixed compilation

* Use IMGUI_IMPL_OPENGL_LOADER_CUSTOM

* Fix up StormLib modifications

* Handle touch events at ImGui/SDL level

* Enable opening menu with -

* Load Nintendo Switch font

* Updates to window initiation

* Handle virtual keyboard via SDL

* Print OTR missing message to screen

* Rename makefile for Switch

* Some more additional fixes

* Branch creation plus edit

Changed ItemWidth & made label invisible (else issues)
Added a submit button next to the text field

* Removed set_texture_filter on imgui draw

* Readded nintendo switch font

* Fixed randomizer crash

* Fix issue with strdup windows

* [SWITCH] Update Jenkins file (#9)

* [SWITCH] Update Jenkins file

* [SWITCH] Dockerfile.switch

Can be combined with other Dockerfile

* [SWITCH] Add entrypoint file

* Update Jenkinsfile

* [SWITCH] Dockerfile mtab link 

link `/proc/self/mounts /etc/mtab`

Co-authored-by: David Chavez <david@dcvz.io>

* Cleaned code based on PR comments

* Fixed switch compilation

* Cleaned full texture cache instead of doing it per char

* Randomizer only saves when its not a vanilla save

* Disabled input when menubar is opened

* Removed return from SetupFont

* Cleaned code based on comments

* Cleaned up random texts on switch error screen

* Killed

* Removed debug and changed compilation flags

Co-authored-by: KiritoDv <nohomoboi01@gmail.com>
Co-authored-by: Felipe Guaycuru <guaycuru@gmail.com>
Co-authored-by: David Chavez <david@dcvz.io>
Co-authored-by: Jeffrey Crowell <github@crowell.biz>
Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>
Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com>
Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: rozlette <Rozelette@users.noreply.github.com>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
Co-authored-by: vaguerant <vaguerant@users.noreply.github.com>
Co-authored-by: earthcrafterman <banddstudios@gmail.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com>
Co-authored-by: Baoulettes <perlouzerie@hotmail.fr>
Co-authored-by: Sirius902 <10891979+Sirius902@users.noreply.github.com>
Co-authored-by: modestposer <modestposer@gmail.com>
Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>
Co-authored-by: Stormghetti <56653191+Stormghetti@users.noreply.github.com>
Co-authored-by: Sirius902 <3645979-Sirius902@users.noreply.gitlab.com>
Co-authored-by: MelonSpeedruns <melonspeedruns@outlook.com>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: Dog <5172592+Dog@users.noreply.github.com>
Co-authored-by: Nicholas Estelami <NEstelami@users.noreply.github.com>
Co-authored-by: ChristopherJTrent <ChristopherJTrent@outlook.com>
Co-authored-by: agamache <aaroncgamache@gmail.com>
Co-authored-by: M4xw <m4x@m4xw.net>
2022-07-25 21:11:53 -04:00
Kenix3 3fc783b832 Merge branch 'develop-zhora' of https://github.com/HarbourMasters/Shipwright into develop-zhora 2022-07-25 19:10:34 -04:00
Jeffrey Crowell c36b891d9b add pkgconfig to the list of dependencies for mac (#923)
* add pkgconfig to the list of dependencies for mac

lots of people are trying to build and they don't have pkg-config in
their paths. hopefully this removes some confusion.

* add cmake to mac deps
2022-07-25 19:07:35 -04:00
Nickelbawker fb64a11d38 Update README.md (#882)
Just trying to prevent people asking what version and where to get the game. I got 2 other copies before finding the right one & I agree with the attitude of some of the people on discord it's not that much effort it didn't take me all that long to do I still think that this will save the world and people helping the project some times not to mention bans.
2022-07-25 19:07:35 -04:00
PurpleHato 26a4622982 ADD: Rando particles on NUTS and STICK Upgrade (#907)
* ADD: Rando particles on NUTS and STICK Upgrade

(Completely forgot they were a thing...)

* TWEAK:  spacing comment
2022-07-25 19:07:35 -04:00
TheLegendOfLame 257cd92208 Adds new features to the Equipment menu Link (#806)
* All features are for the equipment menu:
Added ability to use the right stick for rotate Link enhancement.
Added ability to have analog control on rotating Link.
Added ability to zoom into Link with right stick.
Added ability to have Link do random animations Idle only.

* Added RotationSpeed as a multiplier rather than a hardcoded 2.5
    -Allows for more custom control
    -Also gives purpose for the slider to still be present w/ RStick

* Specifically for the RStick, divided RotationSpeed by 150
    -Even at RotationSpeed 1 it was way too fast

* Added logic to play animations based on what Link has equipped & his age
 - If has sword and shield, all animations
    - Unless he's a kid with the Hylian shield equipped
 - If has sword no shield, all anims but shield anim
 - If has shield no sword, all anims but sword anim
    - Unless he's a kid with the Hylian shield equipped
 - If he has no sword or shield equipped no sword or shield anims

* Casted RotationSpeed to float for RStick and divded by 600.0f
    - Did this instead of dividing by 150, as at RotationSpeed of 20
        the rotation was so fast it was almost nauseating.
        I noticed at RotationSpeed of 5, it was still very quick.
        Logically, another division of 4 was necessary.

* Changed the spacing
2022-07-25 19:07:34 -04:00
Josh Bodner 2d9129084e Add an option to always win the Goron spinning pot jackpot (#913) 2022-07-25 19:07:34 -04:00
lilDavid d6ce37ce7e Add option to allow the ocarina to be played faster (#903)
* Add the ability to play the ocarina really fast like in MM3D

* Clean up CVar condition

* Rename Unlimited Ocarina Speed to Prevent Dropped Ocarina Inputs
2022-07-25 19:07:33 -04:00
GaryOderNichts 6da8ffae11 Controller: zero-initialize wCam values (#902) 2022-07-25 19:07:33 -04:00
vaguerant 62f56a4791 Bug fix: Water Temple gate & bootcommands.c cleanup (#618)
* Vanilla bug fix: child Water Temple gate

* Clean up bootcommands.c
2022-07-25 19:07:32 -04:00
vaguerant 294684213a Timer Savers: Mask Select in Inventory (#670)
* Timer Savers: Mask Select in Inventory

* Merge derp

* Implement suggestions per @briaguya-ai

* Fix cut & paste derp
2022-07-25 19:06:06 -04:00
vaguerant ab691e64db L-button cheats disable minimap toggle (#514)
* L-button cheats disable minimap toggle

* Add debug mode to exclusion list

per @briaguya-ai
2022-07-25 19:06:06 -04:00
earthcrafterman 3a9dd95abc Added a time saver option to allow players to instantly put items away (#600)
* Added a time saver option to allow players to instantly put items away

Expanded the range of damage multiplication to 80 (20 hearts of damage for each quarter heart) so players can play a sudden death challenge

* The damage sliders are now comboboxes
Damage multiplication is now exponential instead of incremental

The FPS slider is now a text input

* Splitting into solely being a quick putaway PR

* Removed some leftover code from the split
2022-07-25 19:06:06 -04:00
David Chavez 706e57dd7b Adds Xcode project (#769)
* Add Xcode project

Add dynamic lib paths

Generate resources scripts

Fix after rebase

tweak targets

Set min deployment target

* remove project

* readd project with correct gitignore
2022-07-25 19:06:06 -04:00
KiritoDev d180b8a299 Added 'Auto' controller backend (#850) 2022-07-25 19:06:05 -04:00
Baoulettes 50bc5de2da Cosmetics editor - Feature requested (#841)
* Precise positionning, reset margin and pos

* Fix big hearts issues

* add + and - to the editor

* add const to the char*

* Fix labels issues
2022-07-25 19:06:05 -04:00
lilDavid 4a15e113f7 Add fixes for power crouch stab to the Enhancements menu (#874)
* Add optional fixes for power crouch stab

* Add line break in "Fix Megaton Hammer" tooltip

Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>

Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
2022-07-25 19:06:05 -04:00
vaguerant 1160fb2b15 Controller option: Navi on L (#861) 2022-07-25 19:06:05 -04:00
Christopher Leggett 27b3644335 Fixes naming discrepancy of textbox positions. (#854)
Equivalent to https://github.com/zeldaret/oot/pull/1329
2022-07-25 19:06:05 -04:00
Jeffrey Crowell b6af684583 allow roms with spaces to be extracted (#868)
using subprocess instead of os.system() is a little safer, and allows
for roms with spaces to be extraced.

i've noticed this is somewhat common in people reporting issues on
discord.
2022-07-25 19:06:05 -04:00
Jeffrey Crowell 1ca64b1fdf add pkgconfig to the list of dependencies for mac (#923)
* add pkgconfig to the list of dependencies for mac

lots of people are trying to build and they don't have pkg-config in
their paths. hopefully this removes some confusion.

* add cmake to mac deps
2022-07-25 18:55:41 -04:00
Nickelbawker 3c1d28b081 Update README.md (#882)
Just trying to prevent people asking what version and where to get the game. I got 2 other copies before finding the right one & I agree with the attitude of some of the people on discord it's not that much effort it didn't take me all that long to do I still think that this will save the world and people helping the project some times not to mention bans.
2022-07-25 18:45:21 -04:00
PurpleHato 5d0452d1dc ADD: Rando particles on NUTS and STICK Upgrade (#907)
* ADD: Rando particles on NUTS and STICK Upgrade

(Completely forgot they were a thing...)

* TWEAK:  spacing comment
2022-07-25 18:44:38 -04:00
TheLegendOfLame d05295aad2 Adds new features to the Equipment menu Link (#806)
* All features are for the equipment menu:
Added ability to use the right stick for rotate Link enhancement.
Added ability to have analog control on rotating Link.
Added ability to zoom into Link with right stick.
Added ability to have Link do random animations Idle only.

* Added RotationSpeed as a multiplier rather than a hardcoded 2.5
    -Allows for more custom control
    -Also gives purpose for the slider to still be present w/ RStick

* Specifically for the RStick, divided RotationSpeed by 150
    -Even at RotationSpeed 1 it was way too fast

* Added logic to play animations based on what Link has equipped & his age
 - If has sword and shield, all animations
    - Unless he's a kid with the Hylian shield equipped
 - If has sword no shield, all anims but shield anim
 - If has shield no sword, all anims but sword anim
    - Unless he's a kid with the Hylian shield equipped
 - If he has no sword or shield equipped no sword or shield anims

* Casted RotationSpeed to float for RStick and divded by 600.0f
    - Did this instead of dividing by 150, as at RotationSpeed of 20
        the rotation was so fast it was almost nauseating.
        I noticed at RotationSpeed of 5, it was still very quick.
        Logically, another division of 4 was necessary.

* Changed the spacing
2022-07-25 12:36:06 +02:00
Christopher Leggett 9f2eb46663 Takes Ganondor's text & hint from CustomMessageTable 2022-07-24 19:43:11 -04:00
Christopher Leggett c1155bb08c Cleans up unused z_message_PAL code. 2022-07-24 19:35:24 -04:00
Christopher Leggett 661946b4f5 Pulls altar text from CustomMessageTable instead of gSaveContext. 2022-07-24 19:34:12 -04:00
Christopher Leggett 780e9f4669 Fixes storage of altar and ganon hints/text.
Only one language is stored in gSaveContext at the moment so store the one language in all 3 CustomMessageEntry languages.
2022-07-24 19:23:54 -04:00
Christopher Leggett a33c3d606a Fixes minor oversight from previous commit. 2022-07-24 18:54:05 -04:00
Christopher Leggett a21998c489 Does some refactoring of rando custom message registration
The goal was less verbosity when adding new get-item messages later.
2022-07-24 18:47:55 -04:00
Christopher Leggett dca922ade8 Merge branch 'develop-zhora' of https://github.com/HarbourMasters/Shipwright into custom-messages 2022-07-24 18:08:10 -04:00
Josh Bodner ffb3523cb5 Add an option to always win the Goron spinning pot jackpot (#913) 2022-07-24 22:00:54 +02:00
lilDavid 62d9390c9b Add option to allow the ocarina to be played faster (#903)
* Add the ability to play the ocarina really fast like in MM3D

* Clean up CVar condition

* Rename Unlimited Ocarina Speed to Prevent Dropped Ocarina Inputs
2022-07-24 09:48:06 -04:00
GaryOderNichts d3c2c0ec7d Controller: zero-initialize wCam values (#902) 2022-07-24 09:37:17 -04:00
vaguerant 38ecb6cfff Bug fix: Water Temple gate & bootcommands.c cleanup (#618)
* Vanilla bug fix: child Water Temple gate

* Clean up bootcommands.c
2022-07-24 09:15:33 -04:00
vaguerant ccf1bffd4f Timer Savers: Mask Select in Inventory (#670)
* Timer Savers: Mask Select in Inventory

* Merge derp

* Implement suggestions per @briaguya-ai

* Fix cut & paste derp
2022-07-24 09:14:36 -04:00
vaguerant 1de5b72802 L-button cheats disable minimap toggle (#514)
* L-button cheats disable minimap toggle

* Add debug mode to exclusion list

per @briaguya-ai
2022-07-24 09:13:43 -04:00
David Chavez d299284751 Merge pull request #878 from dcvz/develop-zhora-merge
Rachael -> Zhora
2022-07-22 03:01:16 +02:00
David Chavez b3d3148383 Merge branch 'develop-rachael' into develop-zhora 2022-07-22 02:34:55 +02:00
earthcrafterman 2ad78887b9 Added a time saver option to allow players to instantly put items away (#600)
* Added a time saver option to allow players to instantly put items away

Expanded the range of damage multiplication to 80 (20 hearts of damage for each quarter heart) so players can play a sudden death challenge

* The damage sliders are now comboboxes
Damage multiplication is now exponential instead of incremental

The FPS slider is now a text input

* Splitting into solely being a quick putaway PR

* Removed some leftover code from the split
2022-07-22 02:31:49 +02:00
David Chavez 1ca12feaed Adds Xcode project (#769)
* Add Xcode project

Add dynamic lib paths

Generate resources scripts

Fix after rebase

tweak targets

Set min deployment target

* remove project

* readd project with correct gitignore
2022-07-21 20:15:45 -04:00
KiritoDev 1cbaa592d0 Added 'Auto' controller backend (#850) 2022-07-22 01:36:28 +02:00
Baoulettes df756b2ce0 Cosmetics editor - Feature requested (#841)
* Precise positionning, reset margin and pos

* Fix big hearts issues

* add + and - to the editor

* add const to the char*

* Fix labels issues
2022-07-22 01:33:39 +02:00
lilDavid c7c16c39b0 Add fixes for power crouch stab to the Enhancements menu (#874)
* Add optional fixes for power crouch stab

* Add line break in "Fix Megaton Hammer" tooltip

Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>

Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
2022-07-22 01:22:09 +02:00
vaguerant 059045481c Controller option: Navi on L (#861) 2022-07-22 01:21:18 +02:00
Christopher Leggett 44dbd3a8a9 Fixes naming discrepancy of textbox positions. (#854)
Equivalent to https://github.com/zeldaret/oot/pull/1329
2022-07-22 01:13:04 +02:00
Jeffrey Crowell 753031df17 allow roms with spaces to be extracted (#868)
using subprocess instead of os.system() is a little safer, and allows
for roms with spaces to be extraced.

i've noticed this is somewhat common in people reporting issues on
discord.
2022-07-22 01:12:43 +02:00
Christopher Leggett 21c585b2ce Removes randomizer_custom_messages, as I relocated its logic elsewhere. 2022-07-21 13:10:04 -04:00
Christopher Leggett b5dc097587 Cleanup and move most hint logic to CustomMessage.
Haven't removed where rando stores the hints for itself and the ganon and altar hints are still pulled from the randomizer class' local storage, but gossip stone hints are pulled from the custom message table now.
2022-07-21 13:05:15 -04:00
Christopher Leggett c5f66373c3 Adds ability to store and retrieve textbox size and position. 2022-07-19 22:51:39 -04:00
Christopher Leggett 2d1aa1d13a Merge in develop-zhora 2022-07-19 20:28:21 -04:00
Christopher Leggett 32abe61554 Implements a basic CreateMessage function for non-GetItem text. 2022-07-19 00:31:37 -04:00
Christopher Leggett e04b2c80b6 Implements the custom text for gInjectSkulltulaCount.
Also auto-dissmisses the textbox when gSkulltulaFreeze is on. When gInjectSkulltulaCount is off, text is not auto-dismissed just like before, since that is base game text still.
2022-07-17 22:02:22 -04:00
Christopher Leggett 1ed45e1433 Implements adding message tables and retrieving by an ID.
Basically, some external code can choos a unique id and create a message table for itself. The idea is that modders can hook into this as well so they can get their own message table and don't have to worry about conflicting with the base game's textIDs. I have also implemented this setup for Randomizer so that the pre-filled bottles (which didn't exist in the original outside of Ruto's letter) have unique text as compared to the text for the item they are filled with.
2022-07-17 21:03:32 -04:00
Christopher Leggett ee1270f346 more cleanup 2022-07-17 15:29:02 -04:00
Christopher Leggett 98c771cf2c Simplifies the function signature of CustomMessage_RetrieveIfExists. 2022-07-17 15:11:16 -04:00
Christopher Leggett 69d2b5b3a3 Implements function to return custom message if one exists.
`CustomMessage_RetrieveIfExists` is placed at the very beginning of the z_message_PAL.c `Message_OpenText` if statement after any special changes to textIds are made. This function will either return either true or false and if true it will populate the necessary values of font and msgCtx to display said message. It's placement at the beginning also allows for overriding existing textIds to have new information, which will come in handy later.
2022-07-17 15:02:08 -04:00
Christopher Leggett f57a912ca1 Does some cleanup of unecessary code and cases of no string provided. 2022-07-17 13:31:38 -04:00
Christopher Leggett 4eaf70b859 Refactors CustomMessages to not be rando specific.
Pulls the Custom Message related code out into it's own class, which has an initialization phase where other enhancements / future features can create messages during an initialization phase to be stored and retrieved later. Along with this refactoring, the 4 bottle messages from the previous rando-specific system are now created and stored during intialization and retrieved by their getItemId.

Now that it isn't rando specific, the goal is to move anything text changes that are hard-coded into z_message_PAL.c and refactor it so that future text additions/overrides can be done without modifying that file.
2022-07-17 12:34:56 -04:00
Christopher Leggett 3f2111a3e6 Adds text for Bottle with Blue Fire as a demo. 2022-07-15 19:48:49 -04:00
Christopher Leggett 1165e70434 Merge branch 'develop' of https://github.com/HarbourMasters/Shipwright into rando-custom-messages 2022-07-15 19:18:45 -04:00
Christopher Leggett 46df17e29f Added an extra helper function and removed instant text control code from ITEM_OBTAINED 2022-07-14 11:17:43 -04:00
Christopher Leggett 9c57ed6642 Merge branch 'develop' of https://github.com/HarbourMasters/Shipwright into rando-custom-messages 2022-07-14 10:06:05 -04:00
Christopher Leggett cd096ce5e9 Fixes newline function to return correct character. 2022-07-14 00:56:47 -04:00
Christopher Leggett 873995199b Merge branch 'develop' of https://github.com/HarbourMasters/Shipwright into rando-custom-messages 2022-07-14 00:56:17 -04:00
Christopher Leggett 0ae5c4c0f2 Merge branch 'develop' of https://github.com/HarbourMasters/Shipwright into rando-custom-messages 2022-07-14 00:42:00 -04:00
Christopher Leggett a81ecfcfcc Renames the separated custom messages files to prevent conflict. 2022-07-14 00:41:04 -04:00
Christopher Leggett d9277530a2 Refactors custom message code to its own file 2022-07-13 23:35:45 -04:00
Christopher Leggett 14a87f83b3 Makes sure custom get item textboxes match.
Specifically, they are all bottom of the screen and blue.
2022-07-13 21:24:20 -04:00
Christopher Leggett e9ba8f734f Early version of custom messages. 2022-07-13 20:35:42 -04:00
1267 changed files with 68189 additions and 114924 deletions
+40 -1
View File
@@ -9,6 +9,7 @@ __pycache__/
.idea/
cmake-build-debug
venv/
.cache/
# Project-specific ignores
build/
@@ -24,6 +25,10 @@ docs/doxygen/
*.map
*.dump
out.txt
*.sln
*.vcxproj
*.vcxproj.user
*.vcxproj.filters
# Tool artifacts
tools/mipspro7.2_compiler/
@@ -405,4 +410,38 @@ tags
oot.otr
*.sav
shipofharkinian.ini
shipofharkinian.json
shipofharkinian.json
imgui.ini
# Switch Stuff
*.nro
*.nacp
ZAPDTR/ZAPDUtils/lib/*
!/soh/icon.jpg
# Xcode
xcuserdata/
*.xcconfig
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
**/xcshareddata/WorkspaceSettings.xcsettings
# cmake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
*/extract_assets_cmake*
/build*
build.c
+169 -44
View File
@@ -2,22 +2,84 @@
## Windows
1. Requires [Python](https://www.python.org/downloads/) >= 3.6.
2. Install [Visual Studio 2022 Community Edition](https://visualstudio.microsoft.com/vs/community/)
3. In the Visual Studio Installer, install `MSVC v142 - VS 2019 C++`.
4. Clone the Ship of Harkinian repository.
5. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice.
6. Run `OTRExporter/OTRExporter.sln`.
7. Switch the solution to `Release x64`.
8. Build the solution.
9. Launching `OTRExporter/extract_assets.py` will generate an `oot.otr` archive file in `OTRExporter/oot.otr`.
10. Run `soh/soh.sln`
11. Switch the solution to `Release x86` or `Release x64`.
12. Build the solution.
13. Copy the `OTRExporter/oot.otr` archive file to `soh/Release`.
14. Launch `soh.exe`.
Requires:
* At least 8GB of RAM (machines with 4GB have seen complier failures)
* Visual Studio 2022 Community Edition with the C++ feature set
* One of the Windows SDKs that comes with Visual Studio, for example the current Windows 10 version 10.0.19041.0
* The `MSVC v142 - VS 2019 C++ build tools` component of Visual Studio
* Python 3 (can be installed manually or as part of Visual Studio)
* Git (can be installed manually or as part of Visual Studio)
* Cmake (can be installed via chocolatey or manually)
During installation, check the "Desktop development with C++" feature set:
![image](https://user-images.githubusercontent.com/30329717/183511274-d11aceea-7900-46ec-acb6-3f2cc110021a.png)
Doing so should also check one of the Windows SDKs by default. Then, in the installation details in the right-hand column, make sure you also check the v142 toolset.
You can also find the v142 toolset by searching through the individual components tab:
![image](https://user-images.githubusercontent.com/30329717/183521169-ead6a73b-a1bf-4e99-aab8-441746d8f08e.png)
While you're there, you can also install Python 3 and Git if needed.
1. Clone the Ship of Harkinian repository
2. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice
_Note: Instructions assume using powershell_
```powershell
# Navigate to the Shipwright repo within powershell. ie: cd "C:\yourpath\Shipwright"
cd Shipwright
# Setup cmake project
& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 17 2022" -T v142 -A x64 # -DCMAKE_BUILD_TYPE:STRING=Release (if you're packaging)
# or for VS2019
& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 16 2019" -T v142 -A x64
# Extract assets & generate OTR (run this anytime you need to regenerate OTR)
& 'C:\Program Files\CMake\bin\cmake.exe' --build .\build\x64 --target ExtractAssets # --config Release (if you're packaging)
# Compile project
& 'C:\Program Files\CMake\bin\cmake.exe' --build .\build\x64 # --config Release (if you're packaging)
# Now you can run the executable in .\build\x64
# If you need to clean the project you can run
& 'C:\Program Files\CMake\bin\cmake.exe' --build .\build\x64 --target clean
```
### Developing SoH
With the cmake build system you have two options for working on the project:
#### Visual Studio
To develop using Visual Studio you only need to use cmake to generate the solution file:
```powershell
# Generates Ship.sln at `build/x64` for Visual Studio 2022
& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 17 2022" -T v142 -A x64
# or for Visual Studio 2019
& 'C:\Program Files\CMake\bin\cmake' -S . -B "build/x64" -G "Visual Studio 16 2019" -T v142 -A x64
```
#### Visual Studio Code or another editor
To develop using Visual Studio Code or another editor you only need to open the repository in it.
To build you'll need to follow the instructions from the building section.
_Note: If you're using Visual Studio Code, the [cpack plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) makes it very easy to just press run and debug._
_Experimental: You can also use another build system entirely rather than MSVC like [Ninja](https://ninja-build.org/) for possibly better performance._
### Generating the distributable
After compiling the project you can generate the distributable by running:
```powershell
# Go to build folder
cd "build/x64"
# Generate
& 'C:\Program Files\CMake\bin\cpack.exe' -G ZIP
```
## Linux
Requires `gcc >= 10, x11, curl, python3, sdl2 >= 2.0.22, libpng, glew >= 2.2, ninja, cmake, lld`
**Important: For maximum performance make sure you have ninja build tools installed!**
_Note: If you're using Visual Studio Code, the [cpack plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) makes it very easy to just press run and debug._
```bash
# Clone the repo
@@ -25,48 +87,112 @@ git clone https://github.com/HarbourMasters/Shipwright.git
cd Shipwright
# Copy the baserom to the OTRExporter folder
cp <path to your ROM> OTRExporter
# Build the docker image
sudo docker build . -t soh
# Run the docker image with the working directory mounted to /soh
sudo docker run --rm -it -v $(pwd):/soh soh /bin/bash
```
Inside the Docker container:
```bash
# Clone and build StormLib
git clone https://github.com/ladislav-zezula/StormLib external/StormLib
cmake -B external/StormLib/build -S external/StormLib
cmake --build external/StormLib/build
cp external/StormLib/build/libstorm.a external
cp /usr/local/lib/libGLEW.a external
# Generate Ninja project
cmake -H. -Bbuild-cmake -GNinja # -DCMAKE_BUILD_TYPE:STRING=Release (if you're packaging)
# Extract assets & generate OTR (run this anytime you need to regenerate OTR)
cmake --build build-cmake --target ExtractAssets
# Compile the project
cmake --build build-cmake # --config Release (if you're packaging)
cd soh
# Extract the assets/Compile the exporter/Run the exporter
make setup -j$(nproc) OPTFLAGS=-O2 DEBUG=0
# Compile the code
make -j $(nproc) OPTFLAGS=-O2 DEBUG=0
# Now you can run the executable in ./build-cmake/soh/soh.elf
# To develop the project open the repository in VSCode (or your preferred editor)
# If you need to clean the project you can run
cmake --build build-cmake --target clean
```
### Generating a distributable
After compiling the project you can generate a distributable by running of the following:
```bash
# Go to build folder
cd build-cmake
# Generate
cpack -G DEB
cpack -G ZIP
cpack -G External (creates appimage)
```
## macOS
Requires Xcode (or xcode-tools) && `sdl2, libpng, glew, ninja, cmake` (can be installed via homebrew, macports, etc)
**Important: For maximum performance make sure you have ninja build tools installed!**
_Note: If you're using Visual Studio Code, the [cpack plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) makes it very easy to just press run and debug._
1. Requires Xcode (or xcode-tools) && `sdl2, libpng, glew, dylibbundler` (can be installed via brew, etc)
```bash
# Clone the repo
git clone https://github.com/HarbourMasters/Shipwright.git
cd ShipWright
# Copy the baserom to the OTRExporter folder
cp <path to your ROM> OTRExporter
# Generate Ninja project
cmake -H. -Bbuild-cmake -GNinja # -DCMAKE_BUILD_TYPE:STRING=Release (if you're packaging)
# Extract assets & generate OTR (run this anytime you need to regenerate OTR)
cmake --build build-cmake --target ExtractAssets
# Compile the project
cmake --build build-cmake # --config Release (if you're packaging)
cd soh
# Extract the assets/Compile the exporter/Run the exporter
# -jX defines number of cores to use for compilation - lower or remove entirely if having issues
make setup -j8 DEBUG=0
# Compile the code (watch the -j parameter as above)
make -j8 DEBUG=0
# Create macOS app bundle
make appbundle
# Copy oot.otr into the Application Support directory
cp build-cmake/soh/oot.otr ~/Library/Application\ Support/com.shipofharkinian.soh/
# Now you can run the executable file:
./build-cmake/soh/soh-macos
# To develop the project open the repository in VSCode (or your preferred editor)
# If you need to clean the project you can run
cmake --build build-cmake --target clean
```
### Generating a distributable
After compiling the project you can generate a distributable by running of the following:
```bash
# Go to build folder
cd build-cmake
# Generate
cpack
```
## Switch
1. Requires that your build machine is setup with the tools necessary for your platform above
2. Requires that you have the switch build tools installed
3. Clone the Ship of Harkinian repository
4. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice
```bash
cd Shipwright
# Setup cmake project for your host machine
cmake -H. -Bbuild-cmake -GNinja
# Extract assets & generate OTR (run this anytime you need to regenerate OTR)
cmake --build build-cmake --target ExtractAssets
# Setup cmake project for building for Switch
cmake -H. -Bbuild-switch -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake
# Build project and generate nro
cmake --build build-switch --target soh_nro
# Now you can run the executable in ./build-switch/soh/soh.nro
# To develop the project open the repository in VSCode (or your preferred editor)
```
## Wii U
1. Requires that your build machine is setup with the tools necessary for your platform above
2. Requires that you have the Wii U build tools installed
3. Clone the Ship of Harkinian repository
4. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice
```bash
cd Shipwright
# Setup cmake project for your host machine
cmake -H. -Bbuild-cmake -GNinja
# Extract assets & generate OTR (run this anytime you need to regenerate OTR)
cmake --build build-cmake --target ExtractAssets
# Setup cmake project for building for Wii U
cmake -H. -Bbuild-wiiu -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/WiiU.cmake # -DCMAKE_BUILD_TYPE:STRING=Release (if you're packaging)
# Build project and generate rpx
cmake --build build-wiiu --target soh # --target soh_wuhb (for building .wuhb)
# Now you can run the executable in ./build-wiiu/soh/soh.rpx or the Wii U Homebrew Bundle in ./build-wiiu/soh/soh.wuhb
# To develop the project open the repository in VSCode (or your preferred editor)
```
9. Copy your OTR file to ~/Library/Application\ Support/com.shipofharkinian.soh
10. Launch soh app in the soh folder!
# Compatible Roms
```
@@ -85,4 +211,3 @@ Use the `extract_assets.py` script file to run the exporter using any of the fol
4) In a terminal run `python3 extract_assets.py <path_to_rom>`
If the script finds multiple roms the user is prompted which to use. Selection is done using the number keys and then pressing the carriage return key.
+65
View File
@@ -0,0 +1,65 @@
################################################################################
# Command for variable_watch. This command issues error message, if a variable
# is changed. If variable PROPERTY_READER_GUARD_DISABLED is TRUE nothing happens
# variable_watch(<variable> property_reader_guard)
################################################################################
function(property_reader_guard VARIABLE ACCESS VALUE CURRENT_LIST_FILE STACK)
if("${PROPERTY_READER_GUARD_DISABLED}")
return()
endif()
if("${ACCESS}" STREQUAL "MODIFIED_ACCESS")
message(FATAL_ERROR
" Variable ${VARIABLE} is not supposed to be changed.\n"
" It is used only for reading target property ${VARIABLE}.\n"
" Use\n"
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}\" \"<value>\")\n"
" or\n"
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}_<CONFIG>\" \"<value>\")\n"
" instead.\n")
endif()
endfunction()
################################################################################
# Create variable <name> with generator expression that expands to value of
# target property <name>_<CONFIG>. If property is empty or not set then property
# <name> is used instead. Variable <name> has watcher property_reader_guard that
# doesn't allow to edit it.
# create_property_reader(<name>)
# Input:
# name - Name of watched property and output variable
################################################################################
function(create_property_reader NAME)
set(PROPERTY_READER_GUARD_DISABLED TRUE)
set(CONFIG_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}_$<UPPER_CASE:$<CONFIG>>>>")
set(IS_CONFIG_VALUE_EMPTY "$<STREQUAL:${CONFIG_VALUE},>")
set(GENERAL_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}>>")
set("${NAME}" "$<IF:${IS_CONFIG_VALUE_EMPTY},${GENERAL_VALUE},${CONFIG_VALUE}>" PARENT_SCOPE)
variable_watch("${NAME}" property_reader_guard)
endfunction()
################################################################################
# Set property $<name>_${PROPS_CONFIG_U} of ${PROPS_TARGET} to <value>
# set_config_specific_property(<name> <value>)
# Input:
# name - Prefix of property name
# value - New value
################################################################################
function(set_config_specific_property NAME VALUE)
set_target_properties("${PROPS_TARGET}" PROPERTIES "${NAME}_${PROPS_CONFIG_U}" "${VALUE}")
endfunction()
################################################################################
create_property_reader("TARGET_NAME")
create_property_reader("OUTPUT_DIRECTORY")
set_config_specific_property("TARGET_NAME" "${PROPS_TARGET}")
set_config_specific_property("OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("ARCHIVE_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("LIBRARY_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("RUNTIME_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("ARCHIVE_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
set_config_specific_property("LIBRARY_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
set_config_specific_property("RUNTIME_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
+12
View File
@@ -0,0 +1,12 @@
include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake")
set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_SOURCE_DIR}$<$<NOT:$<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}")
if(MSVC)
create_property_reader("DEFAULT_CXX_EXCEPTION_HANDLING")
create_property_reader("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT")
set_target_properties("${PROPS_TARGET}" PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
set_config_specific_property("DEFAULT_CXX_EXCEPTION_HANDLING" "/EHsc")
set_config_specific_property("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT" "/Zi")
endif()
+30
View File
@@ -0,0 +1,30 @@
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_COMPONENTS_ALL "ship" "appimage")
if (NOT CPACK_GENERATOR STREQUAL "External")
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "appimage")
endif()
if (CPACK_GENERATOR MATCHES "DEB|RPM")
# https://unix.stackexchange.com/a/11552/254512
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/ship/bin")#/${CMAKE_PROJECT_VERSION}")
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0)
elseif (CPACK_GENERATOR MATCHES "ZIP")
set(CPACK_PACKAGING_INSTALL_PREFIX "")
endif()
if (CPACK_GENERATOR MATCHES "External")
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
SET(CPACK_MONOLITHIC_INSTALL 1)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/bin")
endif()
if (CPACK_GENERATOR MATCHES "Bundle")
set(CPACK_BUNDLE_NAME "soh")
set(CPACK_BUNDLE_PLIST "macosx/Info.plist")
set(CPACK_BUNDLE_ICON "macosx/soh.icns")
set(CPACK_BUNDLE_STARTUP_COMMAND "../soh/macosx/soh-macos.sh")
set(CPACK_BUNDLE_APPLE_CERT_APP "-")
endif()
+90
View File
@@ -0,0 +1,90 @@
# these are cache variables, so they could be overwritten with -D,
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}"
CACHE STRING "The resulting package name"
)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simple C++ application"
CACHE STRING "Package description for the package metadata"
)
set(CPACK_PACKAGE_VENDOR "Some Company")
set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
SET(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/_packages")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_CONTACT "YOUR@E-MAIL.net")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "YOUR NAME")
#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CPACK_SYSTEM_NAME ${LSB_RELEASE_CODENAME_SHORT})
# package name for deb
# if set, then instead of some-application-0.9.2-Linux.deb
# you'll get some-application_0.9.2_amd64.deb (note the underscores too)
#set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
set( CPACK_DEBIAN_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-${ARCHITECTURE}.deb )
# if you want every group to have its own package,
# although the same happens if this is not sent (so it defaults to ONE_PER_GROUP)
# and CPACK_DEB_COMPONENT_INSTALL is set to YES
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)#ONE_PER_GROUP)
# without this you won't be able to pack only specified component
set(CPACK_DEB_COMPONENT_INSTALL YES)
set(CPACK_EXTERNAL_ENABLE_STAGING YES)
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${PROJECT_BINARY_DIR}/appimage-generate.cmake")
file(GENERATE
OUTPUT "${PROJECT_BINARY_DIR}/appimage-generate.cmake"
CONTENT [[
include(CMakePrintHelpers)
cmake_print_variables(CPACK_TEMPORARY_DIRECTORY)
cmake_print_variables(CPACK_TOPLEVEL_DIRECTORY)
cmake_print_variables(CPACK_PACKAGE_DIRECTORY)
cmake_print_variables(CPACK_PACKAGE_FILE_NAME)
find_program(LINUXDEPLOY_EXECUTABLE
NAMES linuxdeploy linuxdeploy-x86_64.AppImage
PATHS ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy)
if (NOT LINUXDEPLOY_EXECUTABLE)
message(STATUS "Downloading linuxdeploy")
set(LINUXDEPLOY_EXECUTABLE ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy/linuxdeploy)
file(DOWNLOAD
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
${LINUXDEPLOY_EXECUTABLE}
INACTIVITY_TIMEOUT 10
LOG ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy/download.log
STATUS LINUXDEPLOY_DOWNLOAD)
execute_process(COMMAND chmod +x ${LINUXDEPLOY_EXECUTABLE} COMMAND_ECHO STDOUT)
endif()
execute_process(
COMMAND
${CMAKE_COMMAND} -E env
OUTPUT=${CPACK_PACKAGE_FILE_NAME}.appimage
VERSION=$<IF:$<BOOL:${CPACK_PACKAGE_VERSION}>,${CPACK_PACKAGE_VERSION},0.1.0>
${LINUXDEPLOY_EXECUTABLE}
--appimage-extract-and-run
--appdir=${CPACK_TEMPORARY_DIRECTORY}
--executable=$<TARGET_FILE:soh>
$<$<BOOL:$<TARGET_PROPERTY:soh,APPIMAGE_DESKTOP_FILE>>:--desktop-file=$<TARGET_PROPERTY:soh,APPIMAGE_DESKTOP_FILE>>
$<$<BOOL:$<TARGET_PROPERTY:soh,APPIMAGE_ICON_FILE>>:--icon-file=$<TARGET_PROPERTY:soh,APPIMAGE_ICON_FILE>>
--output=appimage
# --verbosity=2
)
]])
endif()
include(CPack)
+248
View File
@@ -0,0 +1,248 @@
# utils file for projects came from visual studio solution with cmake-converter.
################################################################################
# Wrap each token of the command with condition
################################################################################
cmake_policy(PUSH)
cmake_policy(SET CMP0054 NEW)
macro(prepare_commands)
unset(TOKEN_ROLE)
unset(COMMANDS)
foreach(TOKEN ${ARG_COMMANDS})
if("${TOKEN}" STREQUAL "COMMAND")
set(TOKEN_ROLE "KEYWORD")
elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD")
set(TOKEN_ROLE "CONDITION")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(TOKEN_ROLE "COMMAND")
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
set(TOKEN_ROLE "ARG")
endif()
if("${TOKEN_ROLE}" STREQUAL "KEYWORD")
list(APPEND COMMANDS "${TOKEN}")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(CONDITION ${TOKEN})
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
list(APPEND COMMANDS "$<$<NOT:${CONDITION}>:${DUMMY}>$<${CONDITION}:${TOKEN}>")
elseif("${TOKEN_ROLE}" STREQUAL "ARG")
list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>")
endif()
endforeach()
endmacro()
cmake_policy(POP)
################################################################################
# Transform all the tokens to absolute paths
################################################################################
macro(prepare_output)
unset(OUTPUT)
foreach(TOKEN ${ARG_OUTPUT})
if(IS_ABSOLUTE ${TOKEN})
list(APPEND OUTPUT "${TOKEN}")
else()
list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}")
endif()
endforeach()
endmacro()
################################################################################
# Parse add_custom_command_if args.
#
# Input:
# PRE_BUILD - Pre build event option
# PRE_LINK - Pre link event option
# POST_BUILD - Post build event option
# TARGET - Target
# OUTPUT - List of output files
# DEPENDS - List of files on which the command depends
# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND
# condition2 commannd2 args2 ...)
# Output:
# OUTPUT - Output files
# DEPENDS - Files on which the command depends
# COMMENT - Comment
# PRE_BUILD - TRUE/FALSE
# PRE_LINK - TRUE/FALSE
# POST_BUILD - TRUE/FALSE
# TARGET - Target name
# COMMANDS - Prepared commands(every token is wrapped in CONDITION)
# NAME - Unique name for custom target
# STEP - PRE_BUILD/PRE_LINK/POST_BUILD
################################################################################
function(add_custom_command_if_parse_arguments)
cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN})
if(WIN32)
set(DUMMY "cd.")
elseif(UNIX)
set(DUMMY "true")
endif()
prepare_commands()
prepare_output()
set(DEPENDS "${ARG_DEPENDS}")
set(COMMENT "${ARG_COMMENT}")
set(PRE_BUILD "${ARG_PRE_BUILD}")
set(PRE_LINK "${ARG_PRE_LINK}")
set(POST_BUILD "${ARG_POST_BUILD}")
set(TARGET "${ARG_TARGET}")
if(PRE_BUILD)
set(STEP "PRE_BUILD")
elseif(PRE_LINK)
set(STEP "PRE_LINK")
elseif(POST_BUILD)
set(STEP "POST_BUILD")
endif()
set(NAME "${TARGET}_${STEP}")
set(OUTPUT "${OUTPUT}" PARENT_SCOPE)
set(DEPENDS "${DEPENDS}" PARENT_SCOPE)
set(COMMENT "${COMMENT}" PARENT_SCOPE)
set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE)
set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE)
set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE)
set(TARGET "${TARGET}" PARENT_SCOPE)
set(COMMANDS "${COMMANDS}" PARENT_SCOPE)
set(STEP "${STEP}" PARENT_SCOPE)
set(NAME "${NAME}" PARENT_SCOPE)
endfunction()
################################################################################
# Add conditional custom command
#
# Generating Files
# The first signature is for adding a custom command to produce an output:
# add_custom_command_if(
# <OUTPUT output1 [output2 ...]>
# <COMMANDS>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [DEPENDS [depends...]]
# [COMMENT comment]
#
# Build Events
# add_custom_command_if(
# <TARGET target>
# <PRE_BUILD | PRE_LINK | POST_BUILD>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [COMMENT comment]
#
# Input:
# output - Output files the command is expected to produce
# condition - Generator expression for wrapping the command
# command - Command-line(s) to execute at build time.
# args - Command`s args
# depends - Files on which the command depends
# comment - Display the given message before the commands are executed at
# build time.
# PRE_BUILD - Run before any other rules are executed within the target
# PRE_LINK - Run after sources have been compiled but before linking the
# binary
# POST_BUILD - Run after all other rules within the target have been
# executed
################################################################################
function(add_custom_command_if)
add_custom_command_if_parse_arguments(${ARGN})
if(OUTPUT AND TARGET)
message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.")
endif()
if(OUTPUT)
add_custom_command(OUTPUT ${OUTPUT}
${COMMANDS}
DEPENDS ${DEPENDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
elseif(TARGET)
if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
add_custom_target(
${NAME}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
add_dependencies(${TARGET} ${NAME})
else()
add_custom_command(
TARGET ${TARGET}
${STEP}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
endif()
else()
message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.")
endif()
endfunction()
################################################################################
# Use props file for a target and configs
# use_props(<target> <configs...> <props_file>)
# Inside <props_file> there are following variables:
# PROPS_TARGET - <target>
# PROPS_CONFIG - One of <configs...>
# PROPS_CONFIG_U - Uppercase PROPS_CONFIG
# Input:
# target - Target to apply props file
# configs - Build configurations to apply props file
# props_file - CMake script
################################################################################
macro(use_props TARGET CONFIGS PROPS_FILE)
set(PROPS_TARGET "${TARGET}")
foreach(PROPS_CONFIG ${CONFIGS})
string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U)
get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
if(EXISTS "${ABSOLUTE_PROPS_FILE}")
include("${ABSOLUTE_PROPS_FILE}")
else()
message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist")
endif()
endforeach()
endmacro()
################################################################################
# Add compile options to source file
# source_file_compile_options(<source_file> [compile_options...])
# Input:
# source_file - Source file
# compile_options - Options to add to COMPILE_FLAGS property
################################################################################
function(source_file_compile_options SOURCE_FILE)
if("${ARGC}" LESS_EQUAL "1")
return()
endif()
get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS)
if(COMPILE_OPTIONS)
list(APPEND COMPILE_OPTIONS ${ARGN})
else()
set(COMPILE_OPTIONS "${ARGN}")
endif()
set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}")
endfunction()
################################################################################
# Default properties of visual studio projects
################################################################################
set(DEFAULT_CXX_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultCXX.cmake")
function(get_linux_lsb_release_information)
find_program(LSB_RELEASE_EXEC lsb_release)
if(NOT LSB_RELEASE_EXEC)
message(FATAL_ERROR "Could not detect lsb_release executable, can not gather required information")
endif()
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --id OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --release OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --codename OUTPUT_VARIABLE LSB_RELEASE_CODENAME_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LSB_RELEASE_ID_SHORT "${LSB_RELEASE_ID_SHORT}" PARENT_SCOPE)
set(LSB_RELEASE_VERSION_SHORT "${LSB_RELEASE_VERSION_SHORT}" PARENT_SCOPE)
set(LSB_RELEASE_CODENAME_SHORT "${LSB_RELEASE_CODENAME_SHORT}" PARENT_SCOPE)
endfunction()
+191
View File
@@ -0,0 +1,191 @@
#------------------------------------------------------------------------------------------------------------
#
# Automate-VCPKG by Andre Taulien
# ===============================
#
# Project Repository: https://github.com/REGoth-project/Automate-VCPKG
# License ..........: MIT, see end of file.
#
# Based on: https://github.com/sutambe/cpptruths/blob/vcpkg_cmake_blog/cpp0x/vcpkg_test/CMakeLists.txt
#
#
# While [Vcpkg](https://github.com/microsoft/vcpkg) on it's own is awesome, it does add
# a little bit of complexity to getting a project to build. Even more if the one trying
# to compile your application is not too fond of the commandline. Additionally, CMake
# commands tend to get rather long with the toolchain path.
#
# To keep things simple for new users who just want to get the project to build, this
# script offers a solution.
#
# Lets assume your main `CMakelists.txt` looks something like this:
#
# cmake_minimum_required (VERSION 3.12.0)
# project (MyProject)
#
# add_executable(MyExecutable main.c)
#
# To integrate Vcpkg into that `CMakelists.txt`, simple put the following lines before the
# call to `project(MyProject)`:
#
# include(cmake/automate-vcpkg.cmake)
#
# vcpkg_bootstrap()
# vcpkg_install_packages(libsquish physfs)
#
# The call to `vcpkg_bootstrap()` will clone the official Vcpkg repository and bootstrap it.
# If it detected an existing environment variable defining a valid `VCPKG_ROOT`, it will
# update the existing installation of Vcpkg.
#
# Arguments to `vcpkg_install_packages()` are the packages you want to install using Vcpkg.
#
# If you want to keep the possibility for users to chose their own copy of Vcpkg, you can
# simply not run the code snippet mentioned above, something like this will work:
#
# option(SKIP_AUTOMATE_VCPKG "When ON, you will need to built the packages
# required by MyProject on your own or supply your own vcpkg toolchain.")
#
# if (NOT SKIP_AUTOMATE_VCPKG)
# include(cmake/automate-vcpkg.cmake)
#
# vcpkg_bootstrap()
# vcpkg_install_packages(libsquish physfs)
# endif()
#
# Then, the user has to supply the packages on their own, be it through Vcpkg or manually
# specifying their locations.
#------------------------------------------------------------------------------------------------------------
cmake_minimum_required (VERSION 3.12)
if(WIN32)
set(VCPKG_FALLBACK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/vcpkg CACHE STRING "vcpkg configuration directory to use if vcpkg was not installed on the system before")
else()
set(VCPKG_FALLBACK_ROOT ${CMAKE_CURRENT_BINARY_DIR}/.vcpkg CACHE STRING "vcpkg configuration directory to use if vcpkg was not installed on the system before")
endif()
# On Windows, Vcpkg defaults to x86, even on x64 systems. If we're
# doing a 64-bit build, we need to fix that.
if (WIN32)
# Since the compiler checks haven't run yet, we need to figure
# out the value of CMAKE_SIZEOF_VOID_P ourselfs
include(CheckTypeSize)
enable_language(C)
check_type_size("void*" SIZEOF_VOID_P BUILTIN_TYPES_ONLY)
if (SIZEOF_VOID_P EQUAL 8)
message(STATUS "Using Vcpkg triplet 'x64-windows'")
set(VCPKG_TRIPLET x64-windows)
endif()
endif()
if(NOT DEFINED VCPKG_ROOT)
if(NOT DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT ${VCPKG_FALLBACK_ROOT})
else()
set(VCPKG_ROOT $ENV{VCPKG_ROOT})
endif()
endif()
# Installs a new copy of Vcpkg or updates an existing one
macro(vcpkg_bootstrap)
_install_or_update_vcpkg()
# Find out whether the user supplied their own VCPKG toolchain file
if(NOT DEFINED ${CMAKE_TOOLCHAIN_FILE})
# We know this wasn't set before so we need point the toolchain file to the newly found VCPKG_ROOT
set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE STRING "")
# Just setting vcpkg.cmake as toolchain file does not seem to actually pull in the code
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
set(AUTOMATE_VCPKG_USE_SYSTEM_VCPKG OFF)
else()
# VCPKG_ROOT has been defined by the toolchain file already
set(AUTOMATE_VCPKG_USE_SYSTEM_VCPKG ON)
endif()
message(STATUS "Automate VCPKG status:")
message(STATUS " VCPKG_ROOT.....: ${VCPKG_ROOT}")
message(STATUS " VCPKG_EXEC.....: ${VCPKG_EXEC}")
message(STATUS " VCPKG_BOOTSTRAP: ${VCPKG_BOOTSTRAP}")
endmacro()
macro(_install_or_update_vcpkg)
if(NOT EXISTS ${VCPKG_ROOT})
message(STATUS "Cloning vcpkg in ${VCPKG_ROOT}")
execute_process(COMMAND git clone https://github.com/Microsoft/vcpkg.git ${VCPKG_ROOT})
# If a reproducible build is desired (and potentially old libraries are # ok), uncomment the
# following line and pin the vcpkg repository to a specific githash.
# execute_process(COMMAND git checkout 745a0aea597771a580d0b0f4886ea1e3a94dbca6 WORKING_DIRECTORY ${VCPKG_ROOT})
else()
# The following command has no effect if the vcpkg repository is in a detached head state.
message(STATUS "Auto-updating vcpkg in ${VCPKG_ROOT}")
execute_process(COMMAND git pull WORKING_DIRECTORY ${VCPKG_ROOT})
endif()
if(NOT EXISTS ${VCPKG_ROOT}/README.md)
message(FATAL_ERROR "***** FATAL ERROR: Could not clone vcpkg *****")
endif()
if(WIN32)
set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg.exe)
set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.bat)
else()
set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg)
set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.sh)
endif()
if(NOT EXISTS ${VCPKG_EXEC})
message("Bootstrapping vcpkg in ${VCPKG_ROOT}")
execute_process(COMMAND ${VCPKG_BOOTSTRAP} WORKING_DIRECTORY ${VCPKG_ROOT})
endif()
if(NOT EXISTS ${VCPKG_EXEC})
message(FATAL_ERROR "***** FATAL ERROR: Could not bootstrap vcpkg *****")
endif()
endmacro()
# Installs the list of packages given as parameters using Vcpkg
macro(vcpkg_install_packages)
# Need the given list to be space-separated
#string (REPLACE ";" " " PACKAGES_LIST_STR "${ARGN}")
message(STATUS "Installing/Updating the following vcpkg-packages: ${PACKAGES_LIST_STR}")
if (VCPKG_TRIPLET)
set(ENV{VCPKG_DEFAULT_TRIPLET} "${VCPKG_TRIPLET}")
endif()
execute_process(
COMMAND ${VCPKG_EXEC} install ${ARGN}
WORKING_DIRECTORY ${VCPKG_ROOT}
)
endmacro()
# MIT License
#
# Copyright (c) 2019 REGoth-project
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
+215
View File
@@ -0,0 +1,215 @@
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
#set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") - issue with soh compile with MSVC
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
project(Ship LANGUAGES C CXX
VERSION 4.0.2)
set(PROJECT_BUILD_NAME "ZHORA CHARLIE" CACHE STRING "")
set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "")
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
include(CMake/automate-vcpkg.cmake)
set(VCPKG_TRIPLET x64-windows-static)
set(VCPKG_TARGET_TRIPLET x64-windows-static)
vcpkg_bootstrap()
vcpkg_install_packages(zlib bzip2 libpng SDL2 SDL2-net GLEW glfw3)
endif()
################################################################################
# Set target arch type if empty. Visual studio solution generator provides it.
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(NOT CMAKE_VS_PLATFORM_NAME)
set(CMAKE_VS_PLATFORM_NAME "x64")
endif()
message("${CMAKE_VS_PLATFORM_NAME} architecture in use")
if(NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64"
OR "${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32"))
message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} arch is not supported!")
endif()
endif()
################################################################################
# Global configuration types
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
set(CMAKE_C_FLAGS_DEBUG "-O3 -ffast-math")
set(CMAKE_CXX_FLAGS_DEBUG "-O3 -ffast-math")
set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG")
else()
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_OBJCXX_FLAGS_RELEASE "-O2 -DNDEBUG")
endif()
if(NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
endif()
################################################################################
# Global compiler options
################################################################################
if(MSVC)
# remove default flags provided with CMake for MSVC
set(CMAKE_C_FLAGS "")
set(CMAKE_C_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_RELEASE "")
endif()
################################################################################
# Global linker options
################################################################################
if(MSVC)
# remove default flags provided with CMake for MSVC
set(CMAKE_EXE_LINKER_FLAGS "")
set(CMAKE_MODULE_LINKER_FLAGS "")
set(CMAKE_SHARED_LINKER_FLAGS "")
set(CMAKE_STATIC_LINKER_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS}")
endif()
################################################################################
# Common utils
################################################################################
include(CMake/Utils.cmake)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
get_linux_lsb_release_information()
message(STATUS "Linux ${LSB_RELEASE_ID_SHORT} ${LSB_RELEASE_VERSION_SHORT} ${LSB_RELEASE_CODENAME_SHORT}")
else()
message(STATUS ${CMAKE_SYSTEM_NAME})
endif()
################################################################################
# Additional Global Settings(add specific info there)
################################################################################
include(CMake/GlobalSettingsInclude.cmake OPTIONAL)
################################################################################
# Use solution folders feature
################################################################################
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
################################################################################
# Sub-projects
################################################################################
add_subdirectory(libultraship/libultraship ${CMAKE_BINARY_DIR}/libultraship)
add_subdirectory(ZAPDTR/ZAPD ${CMAKE_BINARY_DIR}/ZAPD)
add_subdirectory(ZAPDTR/ZAPDUtils ${CMAKE_BINARY_DIR}/ZAPDUtils)
add_subdirectory(OTRExporter)
add_subdirectory(soh)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|NintendoSwitch|CafeOS")
add_subdirectory(OTRGui)
endif()
set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES)
set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.desktop")
set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon.png")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
install(PROGRAMS "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.sh" DESTINATION . COMPONENT appimage)
endif()
find_package(Python3 COMPONENTS Interpreter)
add_custom_target(
ExtractAssets
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f oot.otr
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>"
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${CMAKE_BINARY_DIR}/soh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
COMMENT "Running asset extraction..."
DEPENDS ZAPD
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr
)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(ImageMagick COMPONENTS convert)
if (ImageMagick_FOUND)
execute_process (
COMMAND ${ImageMagick_convert_EXECUTABLE} soh/macosx/sohIcon.png -resize 512x512 ${CMAKE_BINARY_DIR}/sohIcon.png
OUTPUT_VARIABLE outVar
)
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_custom_target(CreateOSXIcons
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/macosx/soh.iconset
COMMAND sips -z 16 16 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16.png
COMMAND sips -z 32 32 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16@2x.png
COMMAND sips -z 32 32 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32.png
COMMAND sips -z 64 64 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32@2x.png
COMMAND sips -z 128 128 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128.png
COMMAND sips -z 256 256 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128@2x.png
COMMAND sips -z 256 256 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256.png
COMMAND sips -z 512 512 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256@2x.png
COMMAND sips -z 512 512 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512.png
COMMAND cp soh/macosx/sohIcon.png ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512@2x.png
COMMAND iconutil -c icns -o ${CMAKE_BINARY_DIR}/macosx/soh.icns ${CMAKE_BINARY_DIR}/macosx/soh.iconset
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Creating OSX icons ..."
)
add_dependencies(soh CreateOSXIcons)
add_custom_target(Assets ALL
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/OTRGui/assets/extractor" -Ddst_dir="${CMAKE_BINARY_DIR}/assets/extractor" -P "${CMAKE_SOURCE_DIR}/OTRGui/Overwrite.cmake"
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/OTRExporter/assets" -Ddst_dir="${CMAKE_BINARY_DIR}/assets/game" -P "${CMAKE_SOURCE_DIR}/OTRGui/Overwrite.cmake"
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/soh/assets/xml" -Ddst_dir="${CMAKE_BINARY_DIR}/assets/extractor/xmls" -P "${CMAKE_SOURCE_DIR}/OTRGui/Overwrite.cmake"
)
add_dependencies(soh Assets)
install(TARGETS ZAPD DESTINATION ${CMAKE_BINARY_DIR}/assets/extractor)
set(PROGRAM_PERMISSIONS_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
install(DIRECTORY ${CMAKE_BINARY_DIR}/assets
DESTINATION .
PATTERN ZAPD.out
PERMISSIONS ${PROGRAM_PERMISSIONS_EXECUTE}
)
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/soh-macos\" \"\" \"${dirs}\")
")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION . COMPONENT ship RENAME readme.txt )
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_GENERATOR "External")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
set(CPACK_GENERATOR "ZIP")
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_GENERATOR "Bundle")
endif()
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/CMake/Packaging-2.cmake)
include(CMake/Packaging.cmake)
+36 -15
View File
@@ -3,17 +3,18 @@ FROM ubuntu:20.04 as build
ENV LANG C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive
ENV GCCVER=10
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
binutils \
gcc-10 \
g++-10 \
gcc-${GCCVER} \
g++-${GCCVER} \
patchelf \
p7zip-full \
python3.9 \
make \
python3 \
cmake \
make \
curl \
git \
lld \
@@ -21,27 +22,47 @@ RUN apt-get update && \
zlib1g-dev \
libbz2-dev \
libpng-dev \
libgles2-mesa-dev && \
ln -s /usr/bin/g++-10 /usr/bin/g++ && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 && \
gcc --version && \
g++ --version
RUN apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/apt /var/lib/cache /var/lib/log
libgles2-mesa-dev \
wget \
gpg \
imagemagick \
ninja-build && \
apt-get install -y software-properties-common && \
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
apt-add-repository "deb https://apt.kitware.com/ubuntu/ focal main" && \
apt-get update && \
apt-get upgrade -y && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCCVER} 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCCVER} 10
RUN git clone https://github.com/Perlmint/glew-cmake.git && \
cmake glew-cmake && \
make -j$(nproc) && \
make install
ENV SDL2VER=2.0.22
RUN curl -sLO https://libsdl.org/release/SDL2-${SDL2VER}.tar.gz && \
tar -xzf SDL2-${SDL2VER}.tar.gz && \
cd SDL2-${SDL2VER} && \
./configure --prefix=/usr && \
make && make install && \
./configure --build=x86_64-linux-gnu && \
make -j$(nproc) && make install && \
rm ../SDL2-${SDL2VER}.tar.gz && \
cp -av /lib/libSDL* /lib/x86_64-linux-gnu/
cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/
RUN \
ln -sf /proc/self/mounts /etc/mtab && \
mkdir -p /usr/local/share/keyring/ && \
wget -O /usr/local/share/keyring/devkitpro-pub.gpg https://apt.devkitpro.org/devkitpro-pub.gpg && \
echo "deb [signed-by=/usr/local/share/keyring/devkitpro-pub.gpg] https://apt.devkitpro.org stable main" > /etc/apt/sources.list.d/devkitpro.list && \
apt-get update -y && \
apt-get install -y devkitpro-pacman && \
yes | dkp-pacman -Syu switch-dev switch-portlibs wiiu-dev wiiu-portlibs --noconfirm
ENV DEVKITPRO=/opt/devkitpro
ENV DEVKITARM=/opt/devkitpro/devkitARM
ENV DEVKITPPC=/opt/devkitpro/devkitPPC
ENV PATH=$PATH:/opt/devkitpro/portlibs/switch/bin/:$DEVKITPPC/bin
ENV WUT_ROOT=$DEVKITPRO/wut
RUN mkdir /soh
WORKDIR /soh
Vendored
+132 -66
View File
@@ -8,20 +8,41 @@ pipeline {
}
stages {
stage('Generate Assets') {
agent {
label "SoH-Asset-Builders"
}
steps {
timeout(time: 10) {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
userRemoteConfigs: scm.userRemoteConfigs
])
sh '''
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
cmake --build build-cmake --target ExtractAssets --config Release
'''
stash includes: 'soh/assets/**/*', name: 'assets'
}
}
post {
unsuccessful {
step([$class: 'WsCleanup']) // Clean workspace
}
}
}
stage('Build SoH') {
parallel {
stage ('Build Windows') {
options {
timeout(time: 20)
}
environment {
MSBUILD='C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Msbuild\\Current\\Bin\\msbuild.exe'
CONFIG='Release'
OTRPLATFORM='x64'
PLATFORM='x64'
ZIP='C:\\Program Files\\7-Zip\\7z.exe'
PYTHON='C:\\Users\\jenkins\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
CMAKE='C:\\Program Files\\CMake\\bin\\cmake.exe'
CPACK='C:\\Program Files\\CMake\\bin\\cpack.exe'
TOOLSET='v142'
}
agent {
@@ -37,38 +58,19 @@ pipeline {
])
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
bat """
"${env.MSBUILD}" ".\\OTRExporter\\OTRExporter.sln" -t:build -p:Configuration=${env.CONFIG};Platform=${env.OTRPLATFORM};PlatformToolset=${env.TOOLSET};RestorePackagesConfig=true /restore /nodeReuse:false /m
xcopy "..\\..\\ZELOOTD.z64" "OTRExporter\\"
cd "OTRExporter"
"${env.PYTHON}" ".\\extract_assets.py"
cd "..\\"
"${env.MSBUILD}" ".\\soh\\soh.sln" -t:build -p:Configuration=${env.CONFIG};Platform=${env.PLATFORM};PlatformToolset=${env.TOOLSET} /nodeReuse:false /m
cd OTRGui
mkdir build
cd build
"${env.CMAKE}" ..
"${env.CMAKE}" --build . --config Release
unstash 'assets'
bat """
"${env.CMAKE}" -S . -B "build\\${env.PLATFORM}" -G "Visual Studio 17 2022" -T ${env.TOOLSET} -A ${env.PLATFORM} -D Python_EXECUTABLE=${env.PYTHON} -D CMAKE_BUILD_TYPE:STRING=Release
"${env.CMAKE}" --build ".\\build\\${env.PLATFORM}" --target OTRGui --config Release
"${env.CMAKE}" --build ".\\build\\${env.PLATFORM}" --config Release
cd ".\\build\\${env.PLATFORM}"
"${env.CPACK}" -G ZIP
cd "..\\..\\"
move "soh\\x64\\Release\\soh.exe" ".\\"
move "OTRGui\\build\\assets" ".\\"
move ".\\OTRExporter\\x64\\Release\\ZAPD.exe" ".\\assets\\extractor\\"
move ".\\OTRGui\\build\\Release\\OTRGui.exe" ".\\"
rename README.md readme.txt
"${env.ZIP}" a soh.7z soh.exe OTRGui.exe assets readme.txt
move "_packages\\*.zip" "soh.zip"
"""
archiveArtifacts artifacts: 'soh.7z', followSymlinks: false, onlyIfSuccessful: true
}
archiveArtifacts artifacts: 'soh.zip', followSymlinks: false, onlyIfSuccessful: true
}
post {
always {
@@ -77,9 +79,6 @@ pipeline {
}
}
stage ('Build Linux') {
options {
timeout(time: 20)
}
agent {
label "SoH-Linux-Builders"
}
@@ -92,32 +91,26 @@ pipeline {
userRemoteConfigs: scm.userRemoteConfigs
])
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
unstash 'assets'
sh '''
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
if docker ps -aq --filter "name=sohcont" | grep -q .; then docker rm -f sohcont; fi
docker build . -t soh
docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash
cp ../../buildsoh.bash soh
docker exec sohcont soh/buildsoh.bash
docker exec sohcont scripts/linux/appimage/build.sh
mkdir build
mv soh/soh.elf build/
mv OTRGui/build/OTRGui build/
mv OTRGui/build/assets build/
mv ZAPDTR/ZAPD.out build/assets/extractor/
mv README.md readme.txt
docker exec sohcont appimage/appimage.sh
7z a soh-linux.7z SOH-Linux.AppImage readme.txt
mv build-cmake/*.appimage soh.appimage
7z a soh-linux.7z soh.appimage readme.txt
'''
}
sh 'sudo docker container stop sohcont'
archiveArtifacts artifacts: 'soh-linux.7z', followSymlinks: false, onlyIfSuccessful: true
}
post {
always {
sh 'sudo docker container stop sohcont'
sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images
step([$class: 'WsCleanup']) // Clean workspace
}
}
@@ -126,11 +119,6 @@ pipeline {
agent {
label "SoH-Mac-Builders"
}
environment {
CC = 'clang -arch arm64 -arch x86_64'
CXX = 'clang++ -arch arm64 -arch x86_64'
MACOSX_DEPLOYMENT_TARGET = 10.15
}
steps {
checkout([
$class: 'GitSCM',
@@ -140,17 +128,19 @@ pipeline {
userRemoteConfigs: scm.userRemoteConfigs
])
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
unstash 'assets'
sh '''
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
cd soh
make setup -j4 OPTFLAGS=-O2 DEBUG=0 LD="ld"
make -j4 DEBUG=0 OPTFLAGS=-O2 LD="ld"
make -j4 appbundle
mv ../README.md readme.txt
7z a soh-mac.7z soh.app readme.txt
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
cmake --build build-cmake --config Release --
(cd build-cmake && cpack)
mv README.md readme.txt
mv _packages/*.dmg SoH.dmg
7z a soh-mac.7z SoH.dmg readme.txt
'''
}
archiveArtifacts artifacts: 'soh/soh-mac.7z', followSymlinks: false, onlyIfSuccessful: true
archiveArtifacts artifacts: 'soh-mac.7z', followSymlinks: false, onlyIfSuccessful: true
}
post {
always {
@@ -158,7 +148,83 @@ pipeline {
}
}
}
stage ('Build Switch') {
agent {
label "SoH-Linux-Builders"
}
steps {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
userRemoteConfigs: scm.userRemoteConfigs
])
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
unstash 'assets'
sh '''
if docker ps -aq --filter "name=sohswitchcont" | grep -q .; then docker rm -f sohswitchcont; fi
docker build . -t sohswitch
docker run --name sohswitchcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash
docker exec sohswitchcont scripts/switch/build.sh
mv build-switch/soh/*.nro soh.nro
mv README.md readme.txt
7z a soh-switch.7z soh.nro readme.txt
'''
}
archiveArtifacts artifacts: 'soh-switch.7z', followSymlinks: false, onlyIfSuccessful: true
}
post {
always {
sh 'sudo docker container stop sohswitchcont'
sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images
step([$class: 'WsCleanup']) // Clean workspace
}
}
}
stage ('Build Wii U') {
agent {
label "SoH-Linux-Builders"
}
steps {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
userRemoteConfigs: scm.userRemoteConfigs
])
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
unstash 'assets'
sh '''
if docker ps -aq --filter "name=sohwiiucont" | grep -q .; then docker rm -f sohwiiucont; fi
docker build . -t sohwiiu
docker run --name sohwiiucont -dit --rm -v $(pwd):/soh sohwiiu /bin/bash
docker exec sohwiiucont scripts/wiiu/build.sh
mv build-wiiu/soh/*.rpx soh.rpx
mv build-wiiu/soh/*.wuhb soh.wuhb
mv README.md readme.txt
7z a soh-wiiu.7z soh.rpx soh.wuhb readme.txt
'''
}
archiveArtifacts artifacts: 'soh-wiiu.7z', followSymlinks: false, onlyIfSuccessful: true
}
post {
always {
sh 'sudo docker container stop sohwiiucont'
sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images
step([$class: 'WsCleanup']) // Clean workspace
}
}
}
}
}
}
}
+65
View File
@@ -0,0 +1,65 @@
################################################################################
# Command for variable_watch. This command issues error message, if a variable
# is changed. If variable PROPERTY_READER_GUARD_DISABLED is TRUE nothing happens
# variable_watch(<variable> property_reader_guard)
################################################################################
function(property_reader_guard VARIABLE ACCESS VALUE CURRENT_LIST_FILE STACK)
if("${PROPERTY_READER_GUARD_DISABLED}")
return()
endif()
if("${ACCESS}" STREQUAL "MODIFIED_ACCESS")
message(FATAL_ERROR
" Variable ${VARIABLE} is not supposed to be changed.\n"
" It is used only for reading target property ${VARIABLE}.\n"
" Use\n"
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}\" \"<value>\")\n"
" or\n"
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}_<CONFIG>\" \"<value>\")\n"
" instead.\n")
endif()
endfunction()
################################################################################
# Create variable <name> with generator expression that expands to value of
# target property <name>_<CONFIG>. If property is empty or not set then property
# <name> is used instead. Variable <name> has watcher property_reader_guard that
# doesn't allow to edit it.
# create_property_reader(<name>)
# Input:
# name - Name of watched property and output variable
################################################################################
function(create_property_reader NAME)
set(PROPERTY_READER_GUARD_DISABLED TRUE)
set(CONFIG_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}_$<UPPER_CASE:$<CONFIG>>>>")
set(IS_CONFIG_VALUE_EMPTY "$<STREQUAL:${CONFIG_VALUE},>")
set(GENERAL_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}>>")
set("${NAME}" "$<IF:${IS_CONFIG_VALUE_EMPTY},${GENERAL_VALUE},${CONFIG_VALUE}>" PARENT_SCOPE)
variable_watch("${NAME}" property_reader_guard)
endfunction()
################################################################################
# Set property $<name>_${PROPS_CONFIG_U} of ${PROPS_TARGET} to <value>
# set_config_specific_property(<name> <value>)
# Input:
# name - Prefix of property name
# value - New value
################################################################################
function(set_config_specific_property NAME VALUE)
set_target_properties("${PROPS_TARGET}" PROPERTIES "${NAME}_${PROPS_CONFIG_U}" "${VALUE}")
endfunction()
################################################################################
create_property_reader("TARGET_NAME")
create_property_reader("OUTPUT_DIRECTORY")
set_config_specific_property("TARGET_NAME" "${PROPS_TARGET}")
set_config_specific_property("OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("ARCHIVE_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("LIBRARY_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("RUNTIME_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("ARCHIVE_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
set_config_specific_property("LIBRARY_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
set_config_specific_property("RUNTIME_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
+12
View File
@@ -0,0 +1,12 @@
include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake")
set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_SOURCE_DIR}$<$<NOT:$<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}")
if(MSVC)
create_property_reader("DEFAULT_CXX_EXCEPTION_HANDLING")
create_property_reader("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT")
set_target_properties("${PROPS_TARGET}" PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
set_config_specific_property("DEFAULT_CXX_EXCEPTION_HANDLING" "/EHsc")
set_config_specific_property("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT" "/Zi")
endif()
+233
View File
@@ -0,0 +1,233 @@
# utils file for projects came from visual studio solution with cmake-converter.
################################################################################
# Wrap each token of the command with condition
################################################################################
cmake_policy(PUSH)
cmake_policy(SET CMP0054 NEW)
macro(prepare_commands)
unset(TOKEN_ROLE)
unset(COMMANDS)
foreach(TOKEN ${ARG_COMMANDS})
if("${TOKEN}" STREQUAL "COMMAND")
set(TOKEN_ROLE "KEYWORD")
elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD")
set(TOKEN_ROLE "CONDITION")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(TOKEN_ROLE "COMMAND")
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
set(TOKEN_ROLE "ARG")
endif()
if("${TOKEN_ROLE}" STREQUAL "KEYWORD")
list(APPEND COMMANDS "${TOKEN}")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(CONDITION ${TOKEN})
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
list(APPEND COMMANDS "$<$<NOT:${CONDITION}>:${DUMMY}>$<${CONDITION}:${TOKEN}>")
elseif("${TOKEN_ROLE}" STREQUAL "ARG")
list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>")
endif()
endforeach()
endmacro()
cmake_policy(POP)
################################################################################
# Transform all the tokens to absolute paths
################################################################################
macro(prepare_output)
unset(OUTPUT)
foreach(TOKEN ${ARG_OUTPUT})
if(IS_ABSOLUTE ${TOKEN})
list(APPEND OUTPUT "${TOKEN}")
else()
list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}")
endif()
endforeach()
endmacro()
################################################################################
# Parse add_custom_command_if args.
#
# Input:
# PRE_BUILD - Pre build event option
# PRE_LINK - Pre link event option
# POST_BUILD - Post build event option
# TARGET - Target
# OUTPUT - List of output files
# DEPENDS - List of files on which the command depends
# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND
# condition2 commannd2 args2 ...)
# Output:
# OUTPUT - Output files
# DEPENDS - Files on which the command depends
# COMMENT - Comment
# PRE_BUILD - TRUE/FALSE
# PRE_LINK - TRUE/FALSE
# POST_BUILD - TRUE/FALSE
# TARGET - Target name
# COMMANDS - Prepared commands(every token is wrapped in CONDITION)
# NAME - Unique name for custom target
# STEP - PRE_BUILD/PRE_LINK/POST_BUILD
################################################################################
function(add_custom_command_if_parse_arguments)
cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN})
if(WIN32)
set(DUMMY "cd.")
elseif(UNIX)
set(DUMMY "true")
endif()
prepare_commands()
prepare_output()
set(DEPENDS "${ARG_DEPENDS}")
set(COMMENT "${ARG_COMMENT}")
set(PRE_BUILD "${ARG_PRE_BUILD}")
set(PRE_LINK "${ARG_PRE_LINK}")
set(POST_BUILD "${ARG_POST_BUILD}")
set(TARGET "${ARG_TARGET}")
if(PRE_BUILD)
set(STEP "PRE_BUILD")
elseif(PRE_LINK)
set(STEP "PRE_LINK")
elseif(POST_BUILD)
set(STEP "POST_BUILD")
endif()
set(NAME "${TARGET}_${STEP}")
set(OUTPUT "${OUTPUT}" PARENT_SCOPE)
set(DEPENDS "${DEPENDS}" PARENT_SCOPE)
set(COMMENT "${COMMENT}" PARENT_SCOPE)
set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE)
set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE)
set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE)
set(TARGET "${TARGET}" PARENT_SCOPE)
set(COMMANDS "${COMMANDS}" PARENT_SCOPE)
set(STEP "${STEP}" PARENT_SCOPE)
set(NAME "${NAME}" PARENT_SCOPE)
endfunction()
################################################################################
# Add conditional custom command
#
# Generating Files
# The first signature is for adding a custom command to produce an output:
# add_custom_command_if(
# <OUTPUT output1 [output2 ...]>
# <COMMANDS>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [DEPENDS [depends...]]
# [COMMENT comment]
#
# Build Events
# add_custom_command_if(
# <TARGET target>
# <PRE_BUILD | PRE_LINK | POST_BUILD>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [COMMENT comment]
#
# Input:
# output - Output files the command is expected to produce
# condition - Generator expression for wrapping the command
# command - Command-line(s) to execute at build time.
# args - Command`s args
# depends - Files on which the command depends
# comment - Display the given message before the commands are executed at
# build time.
# PRE_BUILD - Run before any other rules are executed within the target
# PRE_LINK - Run after sources have been compiled but before linking the
# binary
# POST_BUILD - Run after all other rules within the target have been
# executed
################################################################################
function(add_custom_command_if)
add_custom_command_if_parse_arguments(${ARGN})
if(OUTPUT AND TARGET)
message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.")
endif()
if(OUTPUT)
add_custom_command(OUTPUT ${OUTPUT}
${COMMANDS}
DEPENDS ${DEPENDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
elseif(TARGET)
if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
add_custom_target(
${NAME}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
add_dependencies(${TARGET} ${NAME})
else()
add_custom_command(
TARGET ${TARGET}
${STEP}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
endif()
else()
message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.")
endif()
endfunction()
################################################################################
# Use props file for a target and configs
# use_props(<target> <configs...> <props_file>)
# Inside <props_file> there are following variables:
# PROPS_TARGET - <target>
# PROPS_CONFIG - One of <configs...>
# PROPS_CONFIG_U - Uppercase PROPS_CONFIG
# Input:
# target - Target to apply props file
# configs - Build configurations to apply props file
# props_file - CMake script
################################################################################
macro(use_props TARGET CONFIGS PROPS_FILE)
set(PROPS_TARGET "${TARGET}")
foreach(PROPS_CONFIG ${CONFIGS})
string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U)
get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
if(EXISTS "${ABSOLUTE_PROPS_FILE}")
include("${ABSOLUTE_PROPS_FILE}")
else()
message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist")
endif()
endforeach()
endmacro()
################################################################################
# Add compile options to source file
# source_file_compile_options(<source_file> [compile_options...])
# Input:
# source_file - Source file
# compile_options - Options to add to COMPILE_FLAGS property
################################################################################
function(source_file_compile_options SOURCE_FILE)
if("${ARGC}" LESS_EQUAL "1")
return()
endif()
get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS)
if(COMPILE_OPTIONS)
list(APPEND COMPILE_OPTIONS ${ARGN})
else()
set(COMPILE_OPTIONS "${ARGN}")
endif()
set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}")
endfunction()
################################################################################
# Default properties of visual studio projects
################################################################################
set(DEFAULT_CXX_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultCXX.cmake")
+96
View File
@@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
#set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use")
set(CMAKE_C_STANDARD 11)
project(OTRExporter C CXX)
################################################################################
# Set target arch type if empty. Visual studio solution generator provides it.
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(NOT CMAKE_VS_PLATFORM_NAME)
set(CMAKE_VS_PLATFORM_NAME "x64")
endif()
message("${CMAKE_VS_PLATFORM_NAME} architecture in use")
if(NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64"
OR "${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32"))
message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} arch is not supported!")
endif()
endif()
################################################################################
# Global configuration types
################################################################################
set(CMAKE_CONFIGURATION_TYPES
"Debug"
"Release"
CACHE STRING "" FORCE
)
################################################################################
# Global compiler options
################################################################################
if(MSVC)
# remove default flags provided with CMake for MSVC
set(CMAKE_C_FLAGS "")
set(CMAKE_C_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_RELEASE "")
endif()
################################################################################
# Global linker options
################################################################################
if(MSVC)
# remove default flags provided with CMake for MSVC
set(CMAKE_EXE_LINKER_FLAGS "")
set(CMAKE_MODULE_LINKER_FLAGS "")
set(CMAKE_SHARED_LINKER_FLAGS "")
set(CMAKE_STATIC_LINKER_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS}")
endif()
################################################################################
# Common utils
################################################################################
include(CMake/Utils.cmake)
################################################################################
# Additional Global Settings(add specific info there)
################################################################################
include(CMake/GlobalSettingsInclude.cmake OPTIONAL)
################################################################################
# Use solution folders feature
################################################################################
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
################################################################################
# Sub-projects
################################################################################
if (NOT TARGET libultraship)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../libultraship/libultraship ${CMAKE_BINARY_DIR}/libultraship)
endif()
if (NOT TARGET ZAPD)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPD ${CMAKE_BINARY_DIR}/ZAPD)
endif()
if (NOT TARGET ZAPDUtils)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../ZAPDTR/ZAPDUtils ${CMAKE_BINARY_DIR}/ZAPDUtils)
endif()
add_subdirectory(OTRExporter)
-79
View File
@@ -1,79 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30320.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OTRExporter", "OTRExporter\OTRExporter.vcxproj", "{A6103FD3-0709-4FC7-B066-1A6E056D6306}"
ProjectSection(ProjectDependencies) = postProject
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8} = {6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libultraship", "..\libultraship\libultraship\libultraship.vcxproj", "{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPD", "..\ZAPDTR\ZAPD\ZAPD.vcxproj", "{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}"
ProjectSection(ProjectDependencies) = postProject
{78424708-1F6E-4D4B-920C-FB6D26847055} = {78424708-1F6E-4D4B-920C-FB6D26847055}
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8} = {6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}
{A2E01C3E-D647-45D1-9788-043DEBC1A908} = {A2E01C3E-D647-45D1-9788-043DEBC1A908}
{A6103FD3-0709-4FC7-B066-1A6E056D6306} = {A6103FD3-0709-4FC7-B066-1A6E056D6306}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPDUtils", "..\ZAPDTR\ZAPDUtils\ZAPDUtils.vcxproj", "{A2E01C3E-D647-45D1-9788-043DEBC1A908}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib", "..\StormLib\StormLib_vs19.vcxproj", "{78424708-1F6E-4D4B-920C-FB6D26847055}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Debug|x64.ActiveCfg = Debug|x64
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Debug|x64.Build.0 = Debug|x64
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Debug|x86.ActiveCfg = Debug|Win32
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Debug|x86.Build.0 = Debug|Win32
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Release|x64.ActiveCfg = Release|x64
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Release|x64.Build.0 = Release|x64
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Release|x86.ActiveCfg = Release|Win32
{A6103FD3-0709-4FC7-B066-1A6E056D6306}.Release|x86.Build.0 = Release|Win32
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x64.ActiveCfg = Debug|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x64.Build.0 = Debug|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x86.ActiveCfg = Debug|Win32
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x86.Build.0 = Debug|Win32
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x64.ActiveCfg = Release|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x64.Build.0 = Release|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x86.ActiveCfg = Release|Win32
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x86.Build.0 = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.ActiveCfg = Debug|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.Build.0 = Debug|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.ActiveCfg = Debug|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.Build.0 = Debug|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.ActiveCfg = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.Build.0 = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.ActiveCfg = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.Build.0 = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.ActiveCfg = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.Build.0 = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.ActiveCfg = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.Build.0 = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.ActiveCfg = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.Build.0 = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.ActiveCfg = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.Build.0 = Release|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.ActiveCfg = DebugUS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.Build.0 = DebugUS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x86.ActiveCfg = DebugAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x86.Build.0 = DebugAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.ActiveCfg = ReleaseUS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.Build.0 = ReleaseUS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x86.ActiveCfg = ReleaseAS|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x86.Build.0 = ReleaseAS|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DCE19FF1-37C0-49CD-915A-DD695E15F00B}
EndGlobalSection
EndGlobal
+249
View File
@@ -0,0 +1,249 @@
set(PROJECT_NAME OTRExporter)
################################################################################
# Source groups
################################################################################
set(Header_Files
"AnimationExporter.h"
"ArrayExporter.h"
"AudioExporter.h"
"BackgroundExporter.h"
"BlobExporter.h"
"CollisionExporter.h"
"command_macros_base.h"
"CutsceneExporter.h"
"DisplayListExporter.h"
"Exporter.h"
"Main.h"
"MtxExporter.h"
"PathExporter.h"
"PlayerAnimationExporter.h"
"RoomExporter.h"
"SkeletonExporter.h"
"SkeletonLimbExporter.h"
"TextExporter.h"
"TextureExporter.h"
"VersionInfo.h"
"VtxExporter.h"
"z64cutscene.h"
"z64cutscene_commands.h"
)
source_group("Header Files" FILES ${Header_Files})
set(Source_Files
"AnimationExporter.cpp"
"ArrayExporter.cpp"
"AudioExporter.cpp"
"BackgroundExporter.cpp"
"BlobExporter.cpp"
"CollisionExporter.cpp"
"CutsceneExporter.cpp"
"DisplayListExporter.cpp"
"Exporter.cpp"
"Main.cpp"
"MtxExporter.cpp"
"PathExporter.cpp"
"PlayerAnimationExporter.cpp"
"RoomExporter.cpp"
"SkeletonExporter.cpp"
"SkeletonLimbExporter.cpp"
"TextExporter.cpp"
"TextureExporter.cpp"
"VersionInfo.cpp"
"VtxExporter.cpp"
)
source_group("Source Files" FILES ${Source_Files})
set(ALL_FILES
${Header_Files}
${Source_Files}
)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} STATIC ${ALL_FILES})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
set(ROOT_NAMESPACE OTRExporter)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(${PROJECT_NAME} PROPERTIES
VS_GLOBAL_KEYWORD "Win32Proj"
)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
endif()
endif()
################################################################################
# MSVC runtime library
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR})
endif()
################################################################################
# Compile definitions
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"_CRT_SECURE_NO_WARNINGS"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"WIN32;"
"_CONSOLE;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
)
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
"UNICODE;"
"_UNICODE"
)
endif()
################################################################################
# Compile and link options
################################################################################
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/ZAPD/
${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/ZAPDUtils
${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/lib/tinyxml2
${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/libultraship
${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/libultraship/Lib/spdlog/include
${CMAKE_CURRENT_SOURCE_DIR}/../../libultraship/libultraship/Lib/Fast3D/U64
${CMAKE_CURRENT_SOURCE_DIR}/../../StormLib/src
.
)
if(MSVC)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/Oi;
/Gy
>
/permissive-;
/sdl;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/Oi;
/Gy
>
/permissive-;
/sdl;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
endif()
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/SUBSYSTEM:CONSOLE
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/DEBUG;
/OPT:REF;
/OPT:ICF;
/INCREMENTAL:NO
>
/SUBSYSTEM:CONSOLE
)
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall -Wextra -Wno-error
-Wno-unused-parameter
-Wno-unused-function
-Wno-unused-variable
-Wno-missing-field-initializers
-Wno-parentheses
-Wno-narrowing
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>
)
endif()
################################################################################
# Dependencies
################################################################################
add_dependencies(${PROJECT_NAME}
libultraship
)
# Link with other targets.
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"$<$<CONFIG:Debug>:"
"ZAPDUtils;"
"OTRLib"
">"
)
endif()
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC "${ADDITIONAL_LIBRARY_DEPENDENCIES}")
@@ -653,8 +653,13 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
uint32_t seg = data & 0xFFFFFFFF;
int32_t texAddress = Seg2Filespace(data, dList->parent->baseAddress);
if (!Globals::Instance->HasSegment(GETSEGNUM(seg), res->parent->workerID))
if (!Globals::Instance->HasSegment(GETSEGNUM(seg), res->parent->workerID) || (res->GetName() == "sShadowMaterialDL"))
{
if (res->GetName() == "sShadowMaterialDL") {
// sShadowMaterialDL (In ovl_En_Jsjutan) has a texture in bss. This is a hack to override the reference to one
// to segment C. The actor has been modified to load the texture into segment C.
seg = 0x0C000000;
}
int32_t __ = (data & 0x00FF000000000000) >> 48;
int32_t www = (data & 0x00000FFF00000000) >> 32;
+1 -1
View File
@@ -3,7 +3,7 @@
void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion)
{
writer->Write((uint8_t)Endianess::Little); // 0x00
writer->Write((uint8_t)Endianness::Little); // 0x00
writer->Write((uint8_t)0); // 0x01
writer->Write((uint8_t)0); // 0x02
writer->Write((uint8_t)0); // 0x03
+19 -3
View File
@@ -63,13 +63,29 @@ static void ExporterProgramEnd()
{
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
{
printf("Creating version file...\n");
// Get crc from rom
std::string romPath = Globals::Instance->baseRomPath.string();
std::vector<uint8_t> romData = File::ReadAllBytes(romPath);
uint32_t crc = BitConverter::ToUInt32BE(romData, 0x10);
// Write crc to version file
fs::path versionPath("Extract/version");
std::ofstream versionFile(versionPath.c_str(), std::ios::out | std::ios::binary);
versionFile.write((char*)&crc, sizeof(crc));
versionFile.flush();
versionFile.close();
printf("Created version file.\n");
printf("Generating OTR Archive...\n");
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
for (auto item : files)
{
for (auto item : files) {
auto fileData = item.second;
otrArchive->AddFile(item.first, (uintptr_t)fileData.data(), fileData.size());
otrArchive->AddFile(item.first, (uintptr_t)fileData.data(),
fileData.size());
}
// Add any additional files that need to be manually copied...
-72
View File
@@ -1,72 +0,0 @@
# Only used for standalone compilation, usually inherits these from the main makefile
CXX ?= g++
AR := ar
FORMAT := clang-format-11
ASAN ?= 0
DEBUG ?= 1
OPTFLAGS ?= -O0
LTO ?= 0
WARN := -Wall -Wextra -Werror \
-Wno-unused-parameter \
-Wno-unused-function \
-Wno-unused-variable \
-Wno-error=multichar
CXXFLAGS := $(WARN) -std=c++17
CPPFLAGS := -MMD
ifneq ($(DEBUG),0)
CXXFLAGS += -g
endif
ifneq ($(ASAN),0)
CXXFLAGS += -fsanitize=address
endif
ifneq ($(LTO),0)
CXXFLAGS += -flto
endif
SRC_DIRS := $(shell find . -type d -not -path "*build*")
CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
O_FILES := $(CXX_FILES:%.cpp=build/%.o)
D_FILES := $(O_FILES:%.o=%.d)
LIB := OTRExporter.a
INC_DIRS := $(addprefix -I, \
../../ZAPDTR/ZAPD \
../../ZAPDTR/lib/tinyxml2 \
../../ZAPDTR/lib/libgfxd \
../../ZAPDTR/ZAPDUtils \
../../libultraship/libultraship \
../../libultraship/libultraship/Lib/spdlog/include \
../../libultraship/libultraship/Lib/Fast3D/U64 \
../../StormLib/src \
)
# create build directories
$(shell mkdir -p $(SRC_DIRS:%=build/%))
all: $(LIB)
clean:
rm -rf build $(LIB)
format:
$(FORMAT) -i $(CXX_FILES) $(H_FILES)
.PHONY: all clean format
build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@
$(LIB): $(O_FILES)
$(AR) rcs $@ $^
-include $(D_FILES)
-222
View File
@@ -1,222 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ArrayExporter.h" />
<ClInclude Include="AudioExporter.h" />
<ClInclude Include="BackgroundExporter.h" />
<ClInclude Include="BlobExporter.h" />
<ClInclude Include="CollisionExporter.h" />
<ClInclude Include="command_macros_base.h" />
<ClInclude Include="CutsceneExporter.h" />
<ClInclude Include="DisplayListExporter.h" />
<ClInclude Include="AnimationExporter.h" />
<ClInclude Include="Main.h" />
<ClInclude Include="Exporter.h" />
<ClInclude Include="MtxExporter.h" />
<ClInclude Include="SkeletonExporter.h" />
<ClInclude Include="SkeletonLimbExporter.h" />
<ClInclude Include="PathExporter.h" />
<ClInclude Include="PlayerAnimationExporter.h" />
<ClInclude Include="RoomExporter.h" />
<ClInclude Include="TextExporter.h" />
<ClInclude Include="TextureExporter.h" />
<ClInclude Include="VersionInfo.h" />
<ClInclude Include="VtxExporter.h" />
<ClInclude Include="z64cutscene.h" />
<ClInclude Include="z64cutscene_commands.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ArrayExporter.cpp" />
<ClCompile Include="AudioExporter.cpp" />
<ClCompile Include="BackgroundExporter.cpp" />
<ClCompile Include="BlobExporter.cpp" />
<ClCompile Include="CollisionExporter.cpp" />
<ClCompile Include="CutsceneExporter.cpp" />
<ClCompile Include="DisplayListExporter.cpp" />
<ClCompile Include="AnimationExporter.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="Exporter.cpp" />
<ClCompile Include="MtxExporter.cpp" />
<ClCompile Include="SkeletonExporter.cpp" />
<ClCompile Include="SkeletonLimbExporter.cpp" />
<ClCompile Include="PathExporter.cpp" />
<ClCompile Include="PlayerAnimationExporter.cpp" />
<ClCompile Include="RoomExporter.cpp" />
<ClCompile Include="TextExporter.cpp" />
<ClCompile Include="TextureExporter.cpp" />
<ClCompile Include="VersionInfo.cpp" />
<ClCompile Include="VtxExporter.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OTRGui\build\ZERO_CHECK.vcxproj">
<Project>{02d10590-9542-3f55-aaf8-6055677e2a2a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{a6103fd3-0709-4fc7-b066-1a6e056d6306}</ProjectGuid>
<RootNamespace>OTRExporter</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)otrlib;$(SolutionDir)\ZAPD\ZAPD\;$(SolutionDir)\ZAPD\lib\tinyxml2;$(SolutionDir)\ZAPD\lib\libgfxd;$(SolutionDir)\ZAPD\lib\elfio;$(SolutionDir)\ZAPD\lib\assimp\include;$(SolutionDir)\ZAPD\lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<CodeAnalysisRuleAssemblies />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<CodeAnalysisRuleAssemblies />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir)..\..\ZAPDTR\ZAPD;$(ProjectDir)..\..\ZAPDTR\lib\tinyxml2;$(ProjectDir)..\..\ZAPDTR\lib\libgfxd;$(ProjectDir)..\..\ZAPDTR\ZAPDUtils;$(ProjectDir)..\..\libultraship\libultraship;$(ProjectDir)..\..\libultraship\libultraship\lib\spdlog\include;$(ProjectDir)..\..\libultraship\libultraship\Lib\Fast3D\U64;$(ProjectDir)..\..\StormLib\src\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\libultraship\libultraship;$(LibraryPath)</LibraryPath>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<CodeAnalysisRuleAssemblies />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir)..\..\ZAPDTR\ZAPD;$(ProjectDir)..\..\ZAPDTR\lib\tinyxml2;$(ProjectDir)..\..\ZAPDTR\lib\libgfxd;$(ProjectDir)..\..\ZAPDTR\ZAPDUtils;$(ProjectDir)..\..\libultraship\libultraship;$(ProjectDir)..\..\libultraship\libultraship\lib\spdlog\include;$(ProjectDir)..\..\libultraship\libultraship\Lib\Fast3D\U64;$(ProjectDir)..\..\StormLib\src\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\libultraship\libultraship;$(LibraryPath)</LibraryPath>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules />
<CodeAnalysisRuleAssemblies />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ZAPDUtils.lib;OTRLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,150 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CollisionExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RoomExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TextureExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DisplayListExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Main.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PlayerAnimationExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BackgroundExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VtxExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ArrayExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Exporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AnimationExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CutsceneExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="z64cutscene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="z64cutscene_commands.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="command_macros_base.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PathExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SkeletonExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SkeletonLimbExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TextExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BlobExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MtxExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VersionInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AudioExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CollisionExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RoomExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TextureExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DisplayListExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PlayerAnimationExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SkeletonExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SkeletonLimbExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BackgroundExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VtxExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ArrayExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Exporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AnimationExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CutsceneExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PathExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TextExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BlobExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MtxExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VersionInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AudioExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
+18 -10
View File
@@ -5,19 +5,21 @@ import shutil
from rom_info import Z64Rom
import rom_chooser
import struct
import subprocess
import argparse
def BuildOTR(xmlPath, rom):
def BuildOTR(xmlPath, rom, zapd_exe=None):
shutil.copytree("assets", "Extract/assets")
checksum = int(Z64Rom(rom).checksum.value, 16)
with open("Extract/version", "wb") as f:
f.write(struct.pack('<L', checksum))
if not zapd_exe:
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
execStr += " ed -i %s -b %s -fl CFG/filelists -o placeholder -osf placeholder -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, rom)
exec_cmd = [zapd_exe, "ed", "-i", xmlPath, "-b", rom, "-fl", "CFG/filelists",
"-o", "placeholder", "-osf", "placeholder", "-gsf", "1",
"-rconf", "CFG/Config.xml", "-se", "OTR"]
print(execStr)
exitValue = os.system(execStr)
print(exec_cmd)
exitValue = subprocess.call(exec_cmd)
if exitValue != 0:
print("\n")
print("Error when building the OTR file...", file=os.sys.stderr)
@@ -25,13 +27,19 @@ def BuildOTR(xmlPath, rom):
print("\n")
def main():
rom_path = rom_chooser.chooseROM()
parser = argparse.ArgumentParser()
parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str)
parser.add_argument("rom", help="Path to the rom", type=str, nargs="?")
args = parser.parse_args()
rom_path = args.rom if args.rom else rom_chooser.chooseROM()
rom = Z64Rom(rom_path)
if (os.path.exists("Extract")):
shutil.rmtree("Extract")
BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path)
BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path, zapd_exe=args.zapd_exe)
if __name__ == "__main__":
main()
+1
View File
@@ -36,6 +36,7 @@ class RomVersion:
ROM_INFO_TABLE = dict()
ROM_INFO_TABLE[Checksums.OOT_PAL_GC] = RomVersion("CFG/filelists/gamecube_pal.txt", 0x7170, "GC_NMQ_PAL_F")
ROM_INFO_TABLE[Checksums.OOT_PAL_GC_DBG1] = RomVersion("CFG/filelists/dbg.txt", 0x12F70, "GC_NMQ_D")
ROM_INFO_TABLE[Checksums.OOT_PAL_GC_MQ_DBG] = RomVersion("CFG/filelists/dbg.txt", 0x12F70, "GC_MQ_D")
class RomDmaEntry:
def __init__(self, rom, i):
+65
View File
@@ -0,0 +1,65 @@
################################################################################
# Command for variable_watch. This command issues error message, if a variable
# is changed. If variable PROPERTY_READER_GUARD_DISABLED is TRUE nothing happens
# variable_watch(<variable> property_reader_guard)
################################################################################
function(property_reader_guard VARIABLE ACCESS VALUE CURRENT_LIST_FILE STACK)
if("${PROPERTY_READER_GUARD_DISABLED}")
return()
endif()
if("${ACCESS}" STREQUAL "MODIFIED_ACCESS")
message(FATAL_ERROR
" Variable ${VARIABLE} is not supposed to be changed.\n"
" It is used only for reading target property ${VARIABLE}.\n"
" Use\n"
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}\" \"<value>\")\n"
" or\n"
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}_<CONFIG>\" \"<value>\")\n"
" instead.\n")
endif()
endfunction()
################################################################################
# Create variable <name> with generator expression that expands to value of
# target property <name>_<CONFIG>. If property is empty or not set then property
# <name> is used instead. Variable <name> has watcher property_reader_guard that
# doesn't allow to edit it.
# create_property_reader(<name>)
# Input:
# name - Name of watched property and output variable
################################################################################
function(create_property_reader NAME)
set(PROPERTY_READER_GUARD_DISABLED TRUE)
set(CONFIG_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}_$<UPPER_CASE:$<CONFIG>>>>")
set(IS_CONFIG_VALUE_EMPTY "$<STREQUAL:${CONFIG_VALUE},>")
set(GENERAL_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}>>")
set("${NAME}" "$<IF:${IS_CONFIG_VALUE_EMPTY},${GENERAL_VALUE},${CONFIG_VALUE}>" PARENT_SCOPE)
variable_watch("${NAME}" property_reader_guard)
endfunction()
################################################################################
# Set property $<name>_${PROPS_CONFIG_U} of ${PROPS_TARGET} to <value>
# set_config_specific_property(<name> <value>)
# Input:
# name - Prefix of property name
# value - New value
################################################################################
function(set_config_specific_property NAME VALUE)
set_target_properties("${PROPS_TARGET}" PROPERTIES "${NAME}_${PROPS_CONFIG_U}" "${VALUE}")
endfunction()
################################################################################
create_property_reader("TARGET_NAME")
create_property_reader("OUTPUT_DIRECTORY")
set_config_specific_property("TARGET_NAME" "${PROPS_TARGET}")
set_config_specific_property("OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("ARCHIVE_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("LIBRARY_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("RUNTIME_OUTPUT_NAME" "${TARGET_NAME}")
set_config_specific_property("ARCHIVE_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
set_config_specific_property("LIBRARY_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
set_config_specific_property("RUNTIME_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
+12
View File
@@ -0,0 +1,12 @@
include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake")
set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_SOURCE_DIR}$<$<NOT:$<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}")
if(MSVC)
create_property_reader("DEFAULT_CXX_EXCEPTION_HANDLING")
create_property_reader("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT")
set_target_properties("${PROPS_TARGET}" PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
set_config_specific_property("DEFAULT_CXX_EXCEPTION_HANDLING" "/EHsc")
set_config_specific_property("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT" "/Zi")
endif()
+234
View File
@@ -0,0 +1,234 @@
# utils file for projects came from visual studio solution with cmake-converter.
################################################################################
# Wrap each token of the command with condition
################################################################################
cmake_policy(PUSH)
cmake_policy(SET CMP0054 NEW)
macro(prepare_commands)
unset(TOKEN_ROLE)
unset(COMMANDS)
foreach(TOKEN ${ARG_COMMANDS})
if("${TOKEN}" STREQUAL "COMMAND")
set(TOKEN_ROLE "KEYWORD")
elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD")
set(TOKEN_ROLE "CONDITION")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(TOKEN_ROLE "COMMAND")
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
set(TOKEN_ROLE "ARG")
endif()
if("${TOKEN_ROLE}" STREQUAL "KEYWORD")
list(APPEND COMMANDS "${TOKEN}")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(CONDITION ${TOKEN})
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
list(APPEND COMMANDS "$<$<NOT:${CONDITION}>:${DUMMY}>$<${CONDITION}:${TOKEN}>")
elseif("${TOKEN_ROLE}" STREQUAL "ARG")
list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>")
endif()
endforeach()
endmacro()
cmake_policy(POP)
################################################################################
# Transform all the tokens to absolute paths
################################################################################
macro(prepare_output)
unset(OUTPUT)
foreach(TOKEN ${ARG_OUTPUT})
if(IS_ABSOLUTE ${TOKEN})
list(APPEND OUTPUT "${TOKEN}")
else()
list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}")
endif()
endforeach()
endmacro()
################################################################################
# Parse add_custom_command_if args.
#
# Input:
# PRE_BUILD - Pre build event option
# PRE_LINK - Pre link event option
# POST_BUILD - Post build event option
# TARGET - Target
# OUTPUT - List of output files
# DEPENDS - List of files on which the command depends
# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND
# condition2 commannd2 args2 ...)
# Output:
# OUTPUT - Output files
# DEPENDS - Files on which the command depends
# COMMENT - Comment
# PRE_BUILD - TRUE/FALSE
# PRE_LINK - TRUE/FALSE
# POST_BUILD - TRUE/FALSE
# TARGET - Target name
# COMMANDS - Prepared commands(every token is wrapped in CONDITION)
# NAME - Unique name for custom target
# STEP - PRE_BUILD/PRE_LINK/POST_BUILD
################################################################################
function(add_custom_command_if_parse_arguments)
cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN})
if(WIN32)
set(DUMMY "cd.")
elseif(UNIX)
set(DUMMY "true")
endif()
prepare_commands()
prepare_output()
set(DEPENDS "${ARG_DEPENDS}")
set(COMMENT "${ARG_COMMENT}")
set(PRE_BUILD "${ARG_PRE_BUILD}")
set(PRE_LINK "${ARG_PRE_LINK}")
set(POST_BUILD "${ARG_POST_BUILD}")
set(TARGET "${ARG_TARGET}")
if(PRE_BUILD)
set(STEP "PRE_BUILD")
elseif(PRE_LINK)
set(STEP "PRE_LINK")
elseif(POST_BUILD)
set(STEP "POST_BUILD")
endif()
set(NAME "${TARGET}_${STEP}")
set(OUTPUT "${OUTPUT}" PARENT_SCOPE)
set(DEPENDS "${DEPENDS}" PARENT_SCOPE)
set(COMMENT "${COMMENT}" PARENT_SCOPE)
set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE)
set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE)
set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE)
set(TARGET "${TARGET}" PARENT_SCOPE)
set(COMMANDS "${COMMANDS}" PARENT_SCOPE)
set(STEP "${STEP}" PARENT_SCOPE)
set(NAME "${NAME}" PARENT_SCOPE)
endfunction()
################################################################################
# Add conditional custom command
#
# Generating Files
# The first signature is for adding a custom command to produce an output:
# add_custom_command_if(
# <OUTPUT output1 [output2 ...]>
# <COMMANDS>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [DEPENDS [depends...]]
# [COMMENT comment]
#
# Build Events
# add_custom_command_if(
# <TARGET target>
# <PRE_BUILD | PRE_LINK | POST_BUILD>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [COMMENT comment]
#
# Input:
# output - Output files the command is expected to produce
# condition - Generator expression for wrapping the command
# command - Command-line(s) to execute at build time.
# args - Command`s args
# depends - Files on which the command depends
# comment - Display the given message before the commands are executed at
# build time.
# PRE_BUILD - Run before any other rules are executed within the target
# PRE_LINK - Run after sources have been compiled but before linking the
# binary
# POST_BUILD - Run after all other rules within the target have been
# executed
################################################################################
function(add_custom_command_if)
add_custom_command_if_parse_arguments(${ARGN})
if(OUTPUT AND TARGET)
message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.")
endif()
if(OUTPUT)
add_custom_command(OUTPUT ${OUTPUT}
${COMMANDS}
DEPENDS ${DEPENDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
elseif(TARGET)
if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
add_custom_target(
${NAME}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
add_dependencies(${TARGET} ${NAME})
else()
add_custom_command(
TARGET ${TARGET}
${STEP}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
endif()
else()
message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.")
endif()
endfunction()
################################################################################
# Use props file for a target and configs
# use_props(<target> <configs...> <props_file>)
# Inside <props_file> there are following variables:
# PROPS_TARGET - <target>
# PROPS_CONFIG - One of <configs...>
# PROPS_CONFIG_U - Uppercase PROPS_CONFIG
# Input:
# target - Target to apply props file
# configs - Build configurations to apply props file
# props_file - CMake script
################################################################################
macro(use_props TARGET CONFIGS PROPS_FILE)
set(PROPS_TARGET "${TARGET}")
foreach(PROPS_CONFIG ${CONFIGS})
string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U)
get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
if(EXISTS "${ABSOLUTE_PROPS_FILE}")
include("${ABSOLUTE_PROPS_FILE}")
else()
message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist")
endif()
endforeach()
endmacro()
################################################################################
# Add compile options to source file
# source_file_compile_options(<source_file> [compile_options...])
# Input:
# source_file - Source file
# compile_options - Options to add to COMPILE_FLAGS property
################################################################################
function(source_file_compile_options SOURCE_FILE)
if("${ARGC}" LESS_EQUAL "1")
return()
endif()
get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS)
if(COMPILE_OPTIONS)
list(APPEND COMPILE_OPTIONS ${ARGN})
else()
set(COMPILE_OPTIONS "${ARGN}")
endif()
set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}")
endfunction()
################################################################################
# Default properties of visual studio projects
################################################################################
set(DEFAULT_CXX_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultCXX.cmake")
set(DEFAULT_Fortran_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultFortran.cmake")
+44 -10
View File
@@ -3,27 +3,61 @@ project(OTRGui)
set(PLATFORM "Desktop")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(APP_ICON_RESOURCE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/appicon.rc)
add_subdirectory(libs/raylib)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(OpenGL_GL_PREFERENCE "GLVND")
endif()
include(CMake/Utils.cmake)
add_subdirectory(libs/raylib EXCLUDE_FROM_ALL)
include_directories(src)
include_directories(src/game)
include_directories(include)
include_external_msproject(ZAPD ../../ZAPDTR/ZAPD/ZAPD.vcproj)
include_external_msproject(ZAPDUtils ../../ZAPDTR/ZAPDUtils/ZAPDUtils.vcproj)
include_external_msproject(libultraship ../../libultraship/libultraship/libultraship.vcproj)
include_external_msproject(OTRExporter ../../OTRExporter/OTRExporter/OTRExporter.vcproj)
if (NOT TARGET libultraship)
add_subdirectory(../libultraship/libultraship ${CMAKE_BINARY_DIR}/libultraship)
endif()
if (NOT TARGET ZAPD)
add_subdirectory(../ZAPDTR/ZAPD ${CMAKE_BINARY_DIR}/ZAPD)
endif()
if (NOT TARGET ZAPDUtils)
add_subdirectory(../ZAPDTR/ZAPDUtils ${CMAKE_BINARY_DIR}/ZAPDUtils)
endif()
if (NOT TARGET OTRExporter)
add_subdirectory(../OTRExporter/OTRExporter ${CMAKE_BINARY_DIR}/OTRExporter)
endif()
if (NOT TARGET storm)
add_subdirectory(../StormLib ${CMAKE_BINARY_DIR}/StormLib)
endif()
file(GLOB_RECURSE HEADERS src/*.h)
file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE C_SOURCES src/*.c)
add_executable(${PROJECT_NAME} ${SOURCES} ${C_SOURCES} ${HEADERS} ${APP_ICON_RESOURCE_WINDOWS})
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/assets" -Ddst_dir="${CMAKE_CURRENT_BINARY_DIR}/assets" -P "${CMAKE_CURRENT_SOURCE_DIR}/Overwrite.cmake")
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/../OTRExporter/assets" -Ddst_dir="${CMAKE_CURRENT_BINARY_DIR}/assets/game" -P "${CMAKE_CURRENT_SOURCE_DIR}/Overwrite.cmake")
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_SOURCE_DIR}/../soh/assets/xml" -Ddst_dir="${CMAKE_CURRENT_BINARY_DIR}/assets/extractor/xmls" -P "${CMAKE_CURRENT_SOURCE_DIR}/Overwrite.cmake")
add_executable(${PROJECT_NAME} EXCLUDE_FROM_ALL ${SOURCES} ${C_SOURCES} ${HEADERS} ${APP_ICON_RESOURCE_WINDOWS})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
add_custom_target(Assets ALL
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_CURRENT_SOURCE_DIR}/assets" -Ddst_dir="${CMAKE_CURRENT_BINARY_DIR}/assets" -P "${CMAKE_CURRENT_SOURCE_DIR}/Overwrite.cmake"
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_CURRENT_SOURCE_DIR}/../OTRExporter/assets" -Ddst_dir="${CMAKE_CURRENT_BINARY_DIR}/assets/game" -P "${CMAKE_CURRENT_SOURCE_DIR}/Overwrite.cmake"
COMMAND ${CMAKE_COMMAND} -Dsrc_dir="${CMAKE_CURRENT_SOURCE_DIR}/../soh/assets/xml" -Ddst_dir="${CMAKE_CURRENT_BINARY_DIR}/assets/extractor/xmls" -P "${CMAKE_CURRENT_SOURCE_DIR}/Overwrite.cmake"
)
add_dependencies(OTRGui Assets)
target_link_libraries(${PROJECT_NAME} PUBLIC raylib)
INSTALL(TARGETS OTRGui DESTINATION . COMPONENT ship)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/assets
DESTINATION .
COMPONENT ship
)
INSTALL(TARGETS ZAPD DESTINATION assets/extractor COMPONENT ship)
+9 -4
View File
@@ -1,10 +1,15 @@
file(GLOB_RECURSE _file_list RELATIVE "${src_dir}" "${src_dir}/*")
include(CMakePrintHelpers)
string(REPLACE "\\ " " " sources_dir "${src_dir}")
string(REPLACE "\\ " " " destination_dir "${dst_dir}")
file(GLOB_RECURSE _file_list RELATIVE "${sources_dir}" "${sources_dir}/*")
foreach( each_file ${_file_list} )
set(destinationfile "${dst_dir}/${each_file}")
set(sourcefile "${src_dir}/${each_file}")
set(destinationfile "${destination_dir}/${each_file}")
set(sourcefile "${sources_dir}/${each_file}")
if(NOT EXISTS ${destinationfile} OR ${sourcefile} IS_NEWER_THAN ${destinationfile})
get_filename_component(destinationdir ${destinationfile} DIRECTORY)
file(COPY ${sourcefile} DESTINATION ${destinationdir})
endif()
endforeach(each_file)
endforeach(each_file)
-1
View File
@@ -91,7 +91,6 @@ void ExtractRom()
//MoonUtils::copy("tmp/baserom/Audioseq", "Extract/Audioseq");
//MoonUtils::copy("tmp/baserom/Audiotable", "Extract/Audiotable");
//MoonUtils::copy("tmp/baserom/version", "Extract/version");
MoonUtils::write("Extract/version", (char*)&version.crc, sizeof(version.crc));
MoonUtils::copy("assets/game/", "Extract/assets/");
+3 -3
View File
@@ -29,7 +29,7 @@ std::string GetXMLVersion(RomVersion version)
switch (version.crc)
{
case OOT_PAL_GC_DBG1: return "GC_NMQ_D";
case OOT_PAL_GC_DBG2: return "GC_MQ_D";
case OOT_PAL_GC_MQ_DBG: return "GC_MQ_D";
case OOT_PAL_GC: return "GC_NMQ_PAL_F";
}
@@ -81,7 +81,7 @@ void startWorker(RomVersion version) {
path += GetXMLVersion(version);
Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc));
// Util::write("tmp/baserom/version", (char*)&version.crc, sizeof(version.crc));
if (oldExtractMode)
{
@@ -144,4 +144,4 @@ void updateWorker(const std::string& output) {
std::thread otr(BuildOTR, output);
otr.detach();
}
}
}
+45 -6
View File
@@ -12,7 +12,7 @@ The Ship does not include assets and as such requires a prior copy of the game t
4) Launch `soh.exe`
### Supported Games
#### Ocarina of Time Debug (not Master Quest)
#### Ocarina of Time Debug PAL GC (not Master Quest)
> Currently the recommended option
```
Build team: `zelda@srd022j`
@@ -24,6 +24,13 @@ sha1: cee6bc3c2a634b41728f2af8da54d9bf8cc14099
```
sha1: 0227d7c0074f2d0ac935631990da8ec5914597b4
```
#### Ocarina of Time Debug PAL GC MQ (Dungeons will be Master Quest)
```
Build team: `zelda@srd022j`
Build date: `03-02-21 00:16:31` (year-month-day)
sha1: 079b855b943d6ad8bd1eb026c0ed169ecbdac7da (Produced by decomp)
sha1: 50bebedad9e0f10746a52b07239e47fa6c284d03 (Alternate)
```
Congratulations, you are now sailing with the Ship of Harkinian! Have fun!
@@ -31,10 +38,10 @@ Congratulations, you are now sailing with the Ship of Harkinian! Have fun!
The Ship of Harkinian uses a proprietary versioning system consisting of a sci-fi film character followed by a phonetic alphabet code word. The film character represents a major release version which increments with the addition of many new features and bug fixes. The code word represents a minor release version which increments with small updates mainly comprised of bug fixes. For example, `DECKARD ALFA`.
### The Extraction Tool
### Windows Rom Extraction
* Open a rom to initiate generating the `oot.otr` archive file.
* If a second button exists then `oot.otr` already exists. To prevent overwriting the old `oot.otr` use this button to choose a new game directory. The new directory must not already contain an `oot.otr` to prevent an error.
* Open OTRGui.exe, and select one of the supported roms listed above, to generate the `oot.otr` archive file.
* If a second button already exits then `oot.otr` already exists. To prevent overwriting the old `oot.otr` use this button to choose a new game directory. The new directory must not already contain an `oot.otr` to prevent an error.
* When the process completes, place `oot.otr` beside `soh.exe` if it is not already.
This packaging process can take up to **5 minutes**.
@@ -42,6 +49,37 @@ This packaging process can take up to **5 minutes**.
Close the OTRGui when the `Done!` message appears.
If you get another message, then you might have selected the wrong rom. Make sure to use a rom consistent with the above checksum.
### Linux Rom Extraction
* Place one of the supported roms in the same folder as the appimage.
* When you run the soh appimage, it should begin generating the `oot.otr` archive file.
* When the process completes, place `oot.otr` in the same folder as the appimage, if it is not already, then run the appimage.
The packaging process can take up to **5 minutes**.
If you get any errors, then you might have selected the wrong rom. Make sure to use a rom consistent with the above checksum.
### MacOS Rom Extraction
* Run `soh.app`, and when prompted, select one of the supported roms listed above.
* You should see a notification saying `Processing OTR`, then, once the process is complete, you should get a notification saying `OTR Successfully Generated`, then the game should start.
The packing process can take up to **5 minutes**.
If you get an error saying `Incompatible ROM hash`, you have selected the wrong rom, make sure the checksum matches one of the ones listed above.
### Nintendo Switch Rom Extraction
* Download the latest PC release of the Ship of Harkinian, and follow the instructions above for generating the `oot.otr` archive on that platform.
* Place the `.nro` and the `oot.otr` archive into a folder called `soh` in your Switch folder on your Switch
### Nintendo Wii U Rom Extraction
* Download the latest PC release of the Ship of Harkinian, and follow the instructions above for generating the `oot.otr` archive on that platform.
* Copy the `.rpx` and the `oot.otr` archive to `wiiu/apps/soh`
---
If you still cannot get the tool to work, join our [Discord Server](https://discord.com/invite/BtBmd55HVH) and ask for help in the `#support` text channel. Keep-in-mind that we do not condone piracy in any way.
### Running The Ship of Harkinian
@@ -83,7 +121,7 @@ Refer to the [building instructions](BUILDING.md) to compile SoH.
- Confirm that `zapd.exe` exists in the `/assets/extractor` folder
## Nightly Builds
Nightly builds of Ship of Harkinian are available [here](https://builds.shipofharkinian.com/job/SoH_Multibranch/job/develop)
Nightly builds of Ship of Harkinian are available [here](https://builds.shipofharkinian.com/)
## The Harbour Masters Are...
@@ -123,7 +161,8 @@ Nightly builds of Ship of Harkinian are available [here](https://builds.shipofha
## Video Credits
Kenix | Producer / Writer
rainbow_fash | Executive Producer
briaguya | Writer
rainbow_fash | Executive Producer
ReveriePass | Editor
MicTheMicrophone | Gwonam / The King
Amphibibro | Link
+1
View File
@@ -140,6 +140,7 @@ Desktop.ini
*.egg-info
dist
build
nxbuild
eggs
parts
bin
+86 -2
View File
@@ -1,8 +1,9 @@
project(StormLib)
set(PROJECT_NAME StormLib)
#project(StormLib)
cmake_minimum_required(VERSION 3.10)
set(LIBRARY_NAME storm)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -15,6 +16,13 @@ option(STORM_BUILD_TESTS
# "BUILD_TESTING" OFF # Stay coherent with CTest variables
)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(Source_Files__Windows
src/lzma/C/LzFindMt.c
src/lzma/C/Threads.c
)
endif()
set(SRC_FILES
src/adpcm/adpcm.cpp
src/huffman/huff.cpp
@@ -46,6 +54,7 @@ set(SRC_FILES
src/SFileVerify.cpp
src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c
src/libtomcrypt/src/misc/crypt_libc.c
${Source_Files__Windows}
)
if(MSVC)
@@ -323,11 +332,86 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DO_LARGEFILE=0 -Dstat64=stat -Dlstat64=lstat -Dlseek64=lseek -Doff64_t=off_t -Dfstat64=fstat -Dftruncate64=ftruncate")
endif()
if(NOT WIN32 AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
# Enable POSIX extensions such as `readlink` and `ftruncate`.
add_definitions(-D_POSIX_C_SOURCE=200809L)
endif()
add_library(${LIBRARY_NAME} ${LIB_TYPE} ${SRC_FILES} ${SRC_ADDITIONAL_FILES} ${STORM_DEF_FILES})
if(WIN32)
set_target_properties(${LIBRARY_NAME} PROPERTIES OUTPUT_NAME "StormLib")
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${LIBRARY_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
################################################################################
# Compile definitions
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_definitions(${LIBRARY_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"_CRT_SECURE_NO_WARNINGS;"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
WIN32
_LIB
"UNICODE;"
"_UNICODE"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_definitions(${LIBRARY_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"_CRT_SECURE_NO_WARNINGS;"
">"
"$<$<CONFIG:Release>:"
"NDEBUG;"
">"
"WIN32;"
_LIB
"UNICODE;"
"_UNICODE"
)
endif()
endif()
################################################################################
# MSVC runtime library
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${LIBRARY_NAME} PROPERTY MSVC_RUNTIME_LIBRARY)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
endif()
set_target_properties(${LIBRARY_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR})
endif()
target_link_libraries(${LIBRARY_NAME} ${LINK_LIBS})
target_compile_definitions(${LIBRARY_NAME} INTERFACE STORMLIB_NO_AUTO_LINK) #CMake will take care of the linking
target_include_directories(${LIBRARY_NAME} PUBLIC src/)
+5
View File
@@ -34,7 +34,12 @@
// Local functions - platform-specific functions
#ifndef STORMLIB_WINDOWS
#ifndef STORMLIB_WIIU // WIIU doesn't support thread_local
static thread_local DWORD dwLastError = ERROR_SUCCESS;
#else
static DWORD dwLastError = ERROR_SUCCESS;
#endif
DWORD GetLastError()
{
+4 -4
View File
@@ -2005,7 +2005,7 @@ void ConvertTMPQHeader(void *header, uint16_t version)
TMPQHeader * theHeader = (TMPQHeader *)header;
// Swap header part version 1
if(version == MPQ_FORMAT_VERSION_1)
if(version >= MPQ_FORMAT_VERSION_1)
{
theHeader->dwID = SwapUInt32(theHeader->dwID);
theHeader->dwHeaderSize = SwapUInt32(theHeader->dwHeaderSize);
@@ -2018,21 +2018,21 @@ void ConvertTMPQHeader(void *header, uint16_t version)
theHeader->dwBlockTableSize = SwapUInt32(theHeader->dwBlockTableSize);
}
if(version == MPQ_FORMAT_VERSION_2)
if(version >= MPQ_FORMAT_VERSION_2)
{
theHeader->HiBlockTablePos64 = SwapUInt64(theHeader->HiBlockTablePos64);
theHeader->wHashTablePosHi = SwapUInt16(theHeader->wHashTablePosHi);
theHeader->wBlockTablePosHi = SwapUInt16(theHeader->wBlockTablePosHi);
}
if(version == MPQ_FORMAT_VERSION_3)
if(version >= MPQ_FORMAT_VERSION_3)
{
theHeader->ArchiveSize64 = SwapUInt64(theHeader->ArchiveSize64);
theHeader->BetTablePos64 = SwapUInt64(theHeader->BetTablePos64);
theHeader->HetTablePos64 = SwapUInt64(theHeader->HetTablePos64);
}
if(version == MPQ_FORMAT_VERSION_4)
if(version >= MPQ_FORMAT_VERSION_4)
{
theHeader->HashTableSize64 = SwapUInt64(theHeader->HashTableSize64);
theHeader->BlockTableSize64 = SwapUInt64(theHeader->BlockTableSize64);
+2 -2
View File
@@ -180,7 +180,7 @@ static DWORD LoadAttributesFile(TMPQArchive * ha, LPBYTE pbAttrFile, DWORD cbAtt
if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
return ERROR_FILE_CORRUPT;
BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbCRC32Size);
BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbArraySize);
for(i = 0; i < dwAttributesEntries; i++)
ha->pFileTable[i].dwCrc32 = ArrayCRC32[i];
pbAttrPtr += cbArraySize;
@@ -196,7 +196,7 @@ static DWORD LoadAttributesFile(TMPQArchive * ha, LPBYTE pbAttrFile, DWORD cbAtt
if((pbAttrPtr + cbArraySize) > pbAttrFileEnd)
return ERROR_FILE_CORRUPT;
BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbFileTimeSize);
BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbArraySize);
for(i = 0; i < dwAttributesEntries; i++)
ha->pFileTable[i].FileTime = ArrayFileTime[i];
pbAttrPtr += cbArraySize;
+1 -1
View File
@@ -480,7 +480,7 @@ static bool IsMatchingPatchFile(
{
// Load the patch header
SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL);
BSWAP_ARRAY32_UNSIGNED(pPatchHeader, sizeof(DWORD) * 6);
BSWAP_ARRAY32_UNSIGNED(&PatchHeader, sizeof(DWORD) * 6);
// If the file contains an incremental patch,
// compare the "MD5 before patching" with the base file MD5
+1 -1
View File
@@ -631,8 +631,8 @@ typedef struct _TMPQHash
#else
BYTE Platform;
BYTE Reserved;
BYTE Platform;
USHORT lcLocale;
#endif
+29 -1
View File
@@ -95,7 +95,7 @@
#define PKEXPORT
#ifndef __SYS_ZLIB
#ifndef __SYS_ZLIB
#define __SYS_ZLIB
#endif
@@ -254,6 +254,34 @@
#endif
//-----------------------------------------------------------------------------
// Defines for Wii U platform
#if !defined(STORMLIB_PLATFORM_DEFINED) && defined(__WIIU__)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <assert.h>
#include <errno.h>
#include <malloc.h>
#undef STORMLIB_LITTLE_ENDIAN // Wii U is always big endian
#define STORMLIB_MAC // Use Mac compatible code
#define STORMLIB_WIIU
#define STORMLIB_PLATFORM_DEFINED
#endif
//-----------------------------------------------------------------------------
// Assumption: If the platform is not defined, assume a Linux-like platform
-140
View File
@@ -1,140 +0,0 @@
# use variables in submakes
export
OPTIMIZATION_ON ?= 1
ASAN ?= 0
DEPRECATION_ON ?= 1
DEBUG ?= 0
COPYCHECK_ARGS ?=
LLD ?= 0
WERROR ?= 0
UNAME := $(shell uname)
# Use clang++ if available, else use g++
ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0)
CXX ?= clang++
else
CXX ?= g++
endif
INC := -I ZAPD -I lib/elfio -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils
CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer
OPTFLAGS :=
ifneq ($(DEBUG),0)
OPTIMIZATION_ON = 0
CXXFLAGS += -g3 -DDEVELOPMENT -D_DEBUG
COPYCHECK_ARGS += --devel
DEPRECATION_ON = 0
endif
ifneq ($(WERROR),0)
CXXFLAGS += -Werror
endif
ifeq ($(OPTIMIZATION_ON),0)
OPTFLAGS := -O0
else
OPTFLAGS := -O2
endif
ifneq ($(ASAN),0)
CXXFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined
endif
ifneq ($(DEPRECATION_ON),0)
CXXFLAGS += -DDEPRECATION_ON
endif
# CXXFLAGS += -DTEXTURE_DEBUG
LDFLAGS := -Llib/libgfxd -L../libultraship -L../StormLib/build \
-pthread -lgfxd -lultraship ZAPDUtils/ZAPDUtils.a -lstorm -lbz2 -lm -ldl
ifeq ($(UNAME), Darwin)
LDFLAGS += $(shell pkg-config --libs glew libpng zlib) $(shell sdl2-config --libs) -framework OpenGL -framework Foundation
INC += $(shell pkg-config --cflags libpng)
else
LDFLAGS += -lpng -lGL -lGLEW -lX11 -lz -lSDL2 -lpulse
endif
# Use LLD if available. Set LLD=0 to not use it
ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0)
LLD := 1
endif
ifneq ($(LLD),0)
LDFLAGS += -fuse-ld=lld
endif
UNAMEM := $(shell uname -m)
ifneq ($(UNAME), Darwin)
LDFLAGS += -Wl,-export-dynamic -lstdc++fs
EXPORTERS := -Wl,--whole-archive ../OTRExporter/OTRExporter/OTRExporter.a -Wl,--no-whole-archive
else
EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a
endif
ZAPD_SRC_DIRS := $(shell find ZAPD -type d)
SRC_DIRS = $(ZAPD_SRC_DIRS) lib/tinyxml2
ZAPD_CPP_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.cpp))
ZAPD_H_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.h))
CPP_FILES += $(ZAPD_CPP_FILES) lib/tinyxml2/tinyxml2.cpp
O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f)
O_FILES += build/ZAPD/BuildInfo.o
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
# Main targets
all: ZAPD.out copycheck
build/ZAPD/BuildInfo.o:
python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS)
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp
copycheck: ZAPD.out
python3 copycheck.py
clean:
rm -rf build ZAPD.out
$(MAKE) -C lib/libgfxd clean
$(MAKE) -C ZAPDUtils clean
$(MAKE) -C ExporterTest clean
rm -rf ../StormLib/build
rebuild: clean all
format:
clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
$(MAKE) -C ZAPDUtils format
$(MAKE) -C ExporterTest format
.PHONY: all build/ZAPD/BuildInfo.o copycheck clean rebuild format
build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $<
# Submakes
lib/libgfxd/libgfxd.a:
$(MAKE) -C lib/libgfxd
.PHONY: StormLib
StormLib:
LDFLAGS="" cmake -B ../StormLib/build -S ../StormLib
$(MAKE) -C ../StormLib/build
.PHONY: ExporterTest
ExporterTest:
$(MAKE) -C ExporterTest
.PHONY: ZAPDUtils
ZAPDUtils:
$(MAKE) -C ZAPDUtils
# Linking
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils StormLib
$(CXX) $(CXXFLAGS) $(O_FILES) $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION)
+492
View File
@@ -0,0 +1,492 @@
set(PROJECT_NAME ZAPD)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
#set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use")
set(CMAKE_C_STANDARD 11)
################################################################################
# Source groups
################################################################################
set(Header_Files
"../lib/tinyxml2/tinyxml2.h"
"CRC32.h"
"Declaration.h"
"FileWorker.h"
"GameConfig.h"
"Globals.h"
"ImageBackend.h"
"OutputFormatter.h"
"WarningHandler.h"
)
source_group("Header Files" FILES ${Header_Files})
set(Header_Files__Libraries
"../../libultraship/libultraship/Lib/stb/stb_image.h"
"../../libultraship/libultraship/Lib/stb/stb_image_write.h"
"ctpl_stl.h"
)
source_group("Header Files\\Libraries" FILES ${Header_Files__Libraries})
set(Header_Files__Libraries__elfio
"../lib/elfio/elfio/elf_types.hpp"
"../lib/elfio/elfio/elfio.hpp"
"../lib/elfio/elfio/elfio_dump.hpp"
"../lib/elfio/elfio/elfio_dynamic.hpp"
"../lib/elfio/elfio/elfio_header.hpp"
"../lib/elfio/elfio/elfio_note.hpp"
"../lib/elfio/elfio/elfio_relocation.hpp"
"../lib/elfio/elfio/elfio_section.hpp"
"../lib/elfio/elfio/elfio_segment.hpp"
"../lib/elfio/elfio/elfio_strings.hpp"
"../lib/elfio/elfio/elfio_symbols.hpp"
"../lib/elfio/elfio/elfio_utils.hpp"
)
source_group("Header Files\\Libraries\\elfio" FILES ${Header_Files__Libraries__elfio})
set(Header_Files__Libraries__libgfxd
"../lib/libgfxd/gbi.h"
"../lib/libgfxd/gfxd.h"
"../lib/libgfxd/priv.h"
)
source_group("Header Files\\Libraries\\libgfxd" FILES ${Header_Files__Libraries__libgfxd})
set(Header_Files__Yaz0
"yaz0/readwrite.h"
"yaz0/yaz0.h"
)
source_group("Header Files\\Yaz0" FILES ${Header_Files__Yaz0})
set(Header_Files__Z64
"OtherStructs/SkinLimbStructs.h"
"Overlays/ZOverlay.h"
"ZAnimation.h"
"ZArray.h"
"ZAudio.h"
"ZBackground.h"
"ZBlob.h"
"ZCollision.h"
"ZCutscene.h"
"ZCutsceneMM.h"
"ZDisplayList.h"
"ZFile.h"
"ZLimb.h"
"ZMtx.h"
"ZPath.h"
"ZPlayerAnimationData.h"
"ZResource.h"
"ZRom.h"
"ZScalar.h"
"ZSkeleton.h"
"ZString.h"
"ZSymbol.h"
"ZText.h"
"ZTexture.h"
"ZTextureAnimation.h"
"ZVector.h"
"ZVtx.h"
)
source_group("Header Files\\Z64" FILES ${Header_Files__Z64})
set(Header_Files__Z64__ZRoom
"ZRoom/ZRoom.h"
"ZRoom/ZRoomCommand.h"
)
source_group("Header Files\\Z64\\ZRoom" FILES ${Header_Files__Z64__ZRoom})
set(Header_Files__Z64__ZRoom__Commands
"ZRoom/Commands/EndMarker.h"
"ZRoom/Commands/SetActorCutsceneList.h"
"ZRoom/Commands/SetActorList.h"
"ZRoom/Commands/SetAlternateHeaders.h"
"ZRoom/Commands/SetAnimatedMaterialList.h"
"ZRoom/Commands/SetCameraSettings.h"
"ZRoom/Commands/SetCollisionHeader.h"
"ZRoom/Commands/SetCsCamera.h"
"ZRoom/Commands/SetCutscenes.h"
"ZRoom/Commands/SetEchoSettings.h"
"ZRoom/Commands/SetEntranceList.h"
"ZRoom/Commands/SetExitList.h"
"ZRoom/Commands/SetLightingSettings.h"
"ZRoom/Commands/SetLightList.h"
"ZRoom/Commands/SetMesh.h"
"ZRoom/Commands/SetMinimapChests.h"
"ZRoom/Commands/SetMinimapList.h"
"ZRoom/Commands/SetObjectList.h"
"ZRoom/Commands/SetPathways.h"
"ZRoom/Commands/SetRoomBehavior.h"
"ZRoom/Commands/SetRoomList.h"
"ZRoom/Commands/SetSkyboxModifier.h"
"ZRoom/Commands/SetSkyboxSettings.h"
"ZRoom/Commands/SetSoundSettings.h"
"ZRoom/Commands/SetSpecialObjects.h"
"ZRoom/Commands/SetStartPositionList.h"
"ZRoom/Commands/SetTimeSettings.h"
"ZRoom/Commands/SetTransitionActorList.h"
"ZRoom/Commands/SetWind.h"
"ZRoom/Commands/SetWorldMapVisited.h"
"ZRoom/Commands/Unused09.h"
"ZRoom/Commands/Unused1D.h"
"ZRoom/Commands/ZRoomCommandUnk.h"
)
source_group("Header Files\\Z64\\ZRoom\\Commands" FILES ${Header_Files__Z64__ZRoom__Commands})
set(Resource_Files
"../../OTRExporter/CFG/SymbolMap_OoTMqDbg.txt"
)
source_group("Resource Files" FILES ${Resource_Files})
set(Source_Files
"Declaration.cpp"
"FileWorker.cpp"
"GameConfig.cpp"
"Globals.cpp"
"ImageBackend.cpp"
"Main.cpp"
"OutputFormatter.cpp"
"WarningHandler.cpp"
)
source_group("Source Files" FILES ${Source_Files})
set(Source_Files__Libraries__libgfxd
"../lib/libgfxd/gfxd.c"
"../lib/libgfxd/uc.c"
"../lib/libgfxd/uc_f3d.c"
"../lib/libgfxd/uc_f3db.c"
"../lib/libgfxd/uc_f3dex.c"
"../lib/libgfxd/uc_f3dex2.c"
"../lib/libgfxd/uc_f3dexb.c"
)
source_group("Source Files\\Libraries\\libgfxd" FILES ${Source_Files__Libraries__libgfxd})
set(Source_Files__Yaz0
"yaz0/yaz0.cpp"
)
source_group("Source Files\\Yaz0" FILES ${Source_Files__Yaz0})
set(Source_Files__Z64
"OtherStructs/SkinLimbStructs.cpp"
"Overlays/ZOverlay.cpp"
"ZAnimation.cpp"
"ZArray.cpp"
"ZAudio.cpp"
"ZAudioDecode.cpp"
"ZBackground.cpp"
"ZBlob.cpp"
"ZCollision.cpp"
"ZCutscene.cpp"
"ZCutsceneMM.cpp"
"ZDisplayList.cpp"
"ZFile.cpp"
"ZLimb.cpp"
"ZMtx.cpp"
"ZPath.cpp"
"ZPlayerAnimationData.cpp"
"ZResource.cpp"
"ZRom.cpp"
"ZScalar.cpp"
"ZSkeleton.cpp"
"ZString.cpp"
"ZSymbol.cpp"
"ZText.cpp"
"ZTexture.cpp"
"ZTextureAnimation.cpp"
"ZVector.cpp"
"ZVtx.cpp"
)
source_group("Source Files\\Z64" FILES ${Source_Files__Z64})
set(Source_Files__Z64__ZRoom
"ZRoom/ZRoom.cpp"
"ZRoom/ZRoomCommand.cpp"
)
source_group("Source Files\\Z64\\ZRoom" FILES ${Source_Files__Z64__ZRoom})
set(Source_Files__Z64__ZRoom__Commands
"ZRoom/Commands/EndMarker.cpp"
"ZRoom/Commands/SetActorCutsceneList.cpp"
"ZRoom/Commands/SetActorList.cpp"
"ZRoom/Commands/SetAlternateHeaders.cpp"
"ZRoom/Commands/SetAnimatedMaterialList.cpp"
"ZRoom/Commands/SetCameraSettings.cpp"
"ZRoom/Commands/SetCollisionHeader.cpp"
"ZRoom/Commands/SetCsCamera.cpp"
"ZRoom/Commands/SetCutscenes.cpp"
"ZRoom/Commands/SetEchoSettings.cpp"
"ZRoom/Commands/SetEntranceList.cpp"
"ZRoom/Commands/SetExitList.cpp"
"ZRoom/Commands/SetLightingSettings.cpp"
"ZRoom/Commands/SetLightList.cpp"
"ZRoom/Commands/SetMesh.cpp"
"ZRoom/Commands/SetMinimapChests.cpp"
"ZRoom/Commands/SetMinimapList.cpp"
"ZRoom/Commands/SetObjectList.cpp"
"ZRoom/Commands/SetPathways.cpp"
"ZRoom/Commands/SetRoomBehavior.cpp"
"ZRoom/Commands/SetRoomList.cpp"
"ZRoom/Commands/SetSkyboxModifier.cpp"
"ZRoom/Commands/SetSkyboxSettings.cpp"
"ZRoom/Commands/SetSoundSettings.cpp"
"ZRoom/Commands/SetSpecialObjects.cpp"
"ZRoom/Commands/SetStartPositionList.cpp"
"ZRoom/Commands/SetTimeSettings.cpp"
"ZRoom/Commands/SetTransitionActorList.cpp"
"ZRoom/Commands/SetWind.cpp"
"ZRoom/Commands/SetWorldMapVisited.cpp"
"ZRoom/Commands/Unused09.cpp"
"ZRoom/Commands/Unused1D.cpp"
"ZRoom/Commands/ZRoomCommandUnk.cpp"
)
source_group("Source Files\\Z64\\ZRoom\\Commands" FILES ${Source_Files__Z64__ZRoom__Commands})
set(ALL_FILES
${Header_Files}
${Header_Files__Libraries}
${Header_Files__Libraries__elfio}
${Header_Files__Libraries__libgfxd}
${Header_Files__Yaz0}
${Header_Files__Z64}
${Header_Files__Z64__ZRoom}
${Header_Files__Z64__ZRoom__Commands}
${Resource_Files}
${Source_Files}
${Source_Files__Libraries__libgfxd}
${Source_Files__Yaz0}
${Source_Files__Z64}
${Source_Files__Z64__ZRoom}
${Source_Files__Z64__ZRoom__Commands}
${any__any}
)
################################################################################
# Target
################################################################################
add_executable(${PROJECT_NAME} ${ALL_FILES})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
################################################################################
# Includes for CMake from *.props
################################################################################
set(ROOT_NAMESPACE ZAPD)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME "ZAPD.out"
)
endif()
################################################################################
# MSVC runtime library
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR})
endif()
################################################################################
# Compile definitions
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"_CRT_SECURE_NO_WARNINGS;"
"_MBCS"
STORMLIB_NO_AUTO_LINK
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_CRT_SECURE_NO_WARNINGS"
">"
"_MBCS"
STORMLIB_NO_AUTO_LINK
)
endif()
endif()
################################################################################
# Compile and link options
################################################################################
find_package(PNG REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/ZAPDUtils
${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/lib/tinyxml2
${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/lib/libgfxd
${PNG_PNG_INCLUDE_DIR}/
.
)
if(MSVC)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/Od;
/RTC1
>
$<$<CONFIG:Release>:
/Oi;
/Gy
>
/permissive-;
/sdl;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/Od
>
$<$<CONFIG:Release>:
/O2;
/Oi;
/Gy
>
/permissive-;
/sdl;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
endif()
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/PROFILE
>
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/DEBUG:FULL
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x86")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/PROFILE
>
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/DEBUG:FULL
)
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall -Wextra -Wno-error
-Wno-unused-parameter
-Wno-unused-function
-Wno-unused-variable
-Wno-missing-field-initializers
-Wno-parentheses
-Wno-narrowing
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>
-pthread
)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_link_options(${PROJECT_NAME} PRIVATE
-pthread
)
else()
target_link_options(${PROJECT_NAME} PRIVATE
-pthread
-Wl,-export-dynamic
)
endif()
endif()
################################################################################
# Dependencies
################################################################################
add_dependencies(${PROJECT_NAME}
OTRExporter
ZAPDUtils
libultraship
)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"ZAPDUtils;"
"-WHOLEARCHIVE:$<TARGET_LINKER_FILE_DIR:OTRExporter>/$<TARGET_LINKER_FILE_NAME:OTRExporter>"
"libultraship;"
storm
PNG::PNG
)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"ZAPDUtils;"
-Wl,-force_load $<TARGET_LINKER_FILE_DIR:OTRExporter>/$<TARGET_LINKER_FILE_NAME:OTRExporter>
"libultraship;"
PNG::PNG
${CMAKE_DL_LIBS}
Threads::Threads
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"ZAPDUtils;"
-Wl,--whole-archive $<TARGET_LINKER_FILE_DIR:OTRExporter>/$<TARGET_LINKER_FILE_NAME:OTRExporter> -Wl,--no-whole-archive
"libultraship;"
PNG::PNG
Threads::Threads
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"ZAPDUtils;"
"libultraship;"
PNG::PNG
)
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(ADDITIONAL_LIBRARY_DEPENDENCIES
"ZAPDUtils;"
-Wl,--whole-archive $<TARGET_LINKER_FILE_DIR:OTRExporter>/$<TARGET_LINKER_FILE_NAME:OTRExporter> -Wl,--no-whole-archive
"libultraship;"
PNG::PNG
${CMAKE_DL_LIBS}
Threads::Threads
)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS")
add_library(pathconf OBJECT pathconf.c)
target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}" $<TARGET_OBJECTS:pathconf> )
else()
target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}")
endif()
-6
View File
@@ -359,12 +359,6 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OTRGui\build\ZERO_CHECK.vcxproj">
<Project>{02d10590-9542-3f55-aaf8-6055677e2a2a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\OTRExporter\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\..\OTRExporter\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" />
+5 -2
View File
@@ -348,11 +348,14 @@ std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string&
str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s\"", name.c_str(), outName.c_str(), nameStr.c_str());
if (nameSet && nameSet->find(name) == nameSet->end()) {
str += StringHelper::Sprintf(R"(
#ifdef _WIN32
str += StringHelper::Sprintf("\nstatic const __declspec(align(2)) char %s[] = d%s;", name.c_str(), name.c_str());
static const __declspec(align(2)) char %s[] = d%s;
#else
str += StringHelper::Sprintf("\nstatic const char %s[] __attribute__((aligned (2))) = d%s;", name.c_str(), name.c_str());
static const char %s[] __attribute__((aligned (2))) = d%s;
#endif
)", name.c_str(), name.c_str(), name.c_str(), name.c_str());
if (nameSet) {
nameSet->insert(name);
}
+6
View File
@@ -0,0 +1,6 @@
#include <unistd.h>
long pathconf(const char *path, int name) {
return -1;
}
-82
View File
@@ -1,82 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30320.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPD", "ZAPD\ZAPD.vcxproj", "{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExporterExample", "ExporterTest\ExporterTest.vcxproj", "{65608EB0-1A47-45AD-AB66-192FB64C762C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPDUtils", "ZAPDUtils\ZAPDUtils.vcxproj", "{A2E01C3E-D647-45D1-9788-043DEBC1A908}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
MinSizeRel|x64 = MinSizeRel|x64
MinSizeRel|x86 = MinSizeRel|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
RelWithDebInfo|x64 = RelWithDebInfo|x64
RelWithDebInfo|x86 = RelWithDebInfo|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.ActiveCfg = Debug|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.Build.0 = Debug|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.ActiveCfg = Debug|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.Build.0 = Debug|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x64.ActiveCfg = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x64.Build.0 = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x86.ActiveCfg = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.MinSizeRel|x86.Build.0 = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.ActiveCfg = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.Build.0 = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.ActiveCfg = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.Build.0 = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x64.Build.0 = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.RelWithDebInfo|x86.Build.0 = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x64.ActiveCfg = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x64.Build.0 = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x86.ActiveCfg = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Debug|x86.Build.0 = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x64.ActiveCfg = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x64.Build.0 = Debug|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x86.ActiveCfg = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.MinSizeRel|x86.Build.0 = Debug|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x64.ActiveCfg = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x64.Build.0 = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x86.ActiveCfg = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.Release|x86.Build.0 = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x64.Build.0 = Release|x64
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{65608EB0-1A47-45AD-AB66-192FB64C762C}.RelWithDebInfo|x86.Build.0 = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.ActiveCfg = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.Build.0 = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.ActiveCfg = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.Build.0 = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x64.ActiveCfg = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x64.Build.0 = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x86.ActiveCfg = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.MinSizeRel|x86.Build.0 = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.ActiveCfg = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.Build.0 = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.ActiveCfg = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.Build.0 = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x64.Build.0 = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.RelWithDebInfo|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C2E1CC72-7A50-3249-AFD5-DFF6FE25CDCA}
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal
+218
View File
@@ -0,0 +1,218 @@
set(PROJECT_NAME ZAPDUtils)
################################################################################
# Source groups
################################################################################
set(Header_Files
"Color3b.h"
"StrHash.h"
"Vec2f.h"
"Vec3f.h"
"Vec3s.h"
)
source_group("Header Files" FILES ${Header_Files})
set(Header_Files__Utils
"Utils/BinaryReader.h"
"Utils/BinaryWriter.h"
"Utils/BitConverter.h"
"Utils/Directory.h"
"Utils/File.h"
"Utils/MemoryStream.h"
"Utils/Path.h"
"Utils/Stream.h"
"Utils/StringHelper.h"
)
source_group("Header Files\\Utils" FILES ${Header_Files__Utils})
set(Source_Files__Libraries
"../lib/tinyxml2/tinyxml2.cpp"
)
source_group("Source Files\\Libraries" FILES ${Source_Files__Libraries})
set(Source_Files__Utils
"Utils/BinaryReader.cpp"
"Utils/BinaryWriter.cpp"
"Utils/MemoryStream.cpp"
"Utils/StringHelper.cpp"
)
source_group("Source Files\\Utils" FILES ${Source_Files__Utils})
set(ALL_FILES
${Header_Files}
${Header_Files__Utils}
${Source_Files__Libraries}
${Source_Files__Utils}
)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} STATIC ${ALL_FILES})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
set(ROOT_NAMESPACE ZAPDUtils)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(${PROJECT_NAME} PROPERTIES
VS_GLOBAL_KEYWORD "Win32Proj"
)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
endif()
endif()
################################################################################
# MSVC runtime library
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
MultiThreaded
)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR})
endif()
################################################################################
# Compile definitions
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"_MBCS"
">"
"$<$<CONFIG:Release>:"
"NDEBUG;"
"UNICODE;"
"_UNICODE"
">"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS"
STORMLIB_NO_AUTO_LINK
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"WIN32;"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
)
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
"UNICODE;"
"_UNICODE"
)
endif()
################################################################################
# Compile and link options
################################################################################
if(MSVC)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/Oi;
/Gy
>
/permissive-;
/MP;
/sdl;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/O2;
/Ot
>
$<$<CONFIG:Release>:
/Gy
>
/permissive-;
/MP;
/Oi;
/sdl;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
endif()
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/SUBSYSTEM:CONSOLE
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/SUBSYSTEM:CONSOLE
)
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall -Wextra -Wno-error
-Wno-unused-parameter
-Wno-unused-function
-Wno-unused-variable
-Wno-missing-field-initializers
-Wno-parentheses
-Wno-narrowing
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>
)
endif()
################################################################################
# Dependencies
################################################################################
# Link with other targets.
-29
View File
@@ -1,29 +0,0 @@
# Only used for standalone compilation, usually inherits these from the main makefile
CXX ?= g++
CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17
SRC_DIRS := $(shell find . -type d -not -path "*build*")
CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f)
LIB := ZAPDUtils.a
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
all: $(LIB)
clean:
rm -rf build $(LIB)
format:
clang-format-11 -i $(CPP_FILES) $(H_FILES)
.PHONY: all clean format
build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) -c $(OUTPUT_OPTION) $<
$(LIB): $(O_FILES)
$(AR) rcs $@ $^
+56 -1
View File
@@ -18,6 +18,16 @@ void BinaryReader::Close()
stream->Close();
}
void BinaryReader::SetEndianness(Endianness endianness)
{
this->endianness = endianness;
}
Endianness BinaryReader::GetEndianness() const
{
return endianness;
}
void BinaryReader::Seek(uint32_t offset, SeekOffsetType seekType)
{
stream->Seek(offset, seekType);
@@ -28,11 +38,16 @@ uint32_t BinaryReader::GetBaseAddress()
return stream->GetBaseAddress();
}
void BinaryReader::Read([[maybe_unused]] char* buffer, int32_t length)
void BinaryReader::Read(int32_t length)
{
stream->Read(length);
}
void BinaryReader::Read(char* buffer, int32_t length)
{
stream->Read(buffer, length);
}
char BinaryReader::ReadChar()
{
return (char)stream->ReadByte();
@@ -53,6 +68,10 @@ int16_t BinaryReader::ReadInt16()
int16_t result = 0;
stream->Read((char*)&result, sizeof(int16_t));
if (endianness != Endianness::Native)
result = BSWAP16(result);
return result;
}
@@ -61,6 +80,10 @@ int32_t BinaryReader::ReadInt32()
int32_t result = 0;
stream->Read((char*)&result, sizeof(int32_t));
if (endianness != Endianness::Native)
result = BSWAP32(result);
return result;
}
@@ -69,6 +92,10 @@ uint16_t BinaryReader::ReadUInt16()
uint16_t result = 0;
stream->Read((char*)&result, sizeof(uint16_t));
if (endianness != Endianness::Native)
result = BSWAP16(result);
return result;
}
@@ -77,6 +104,10 @@ uint32_t BinaryReader::ReadUInt32()
uint32_t result = 0;
stream->Read((char*)&result, sizeof(uint32_t));
if (endianness != Endianness::Native)
result = BSWAP32(result);
return result;
}
@@ -85,6 +116,10 @@ uint64_t BinaryReader::ReadUInt64()
uint64_t result = 0;
stream->Read((char*)&result, sizeof(uint64_t));
if (endianness != Endianness::Native)
result = BSWAP64(result);
return result;
}
@@ -94,6 +129,15 @@ float BinaryReader::ReadSingle()
stream->Read((char*)&result, sizeof(float));
if (endianness != Endianness::Native)
{
float tmp;
char* dst = (char*)&tmp;
char* src = (char*)&result;
dst[3] = src[0]; dst[2] = src[1]; dst[1] = src[2]; dst[0] = src[3];
result = tmp;
}
if (std::isnan(result))
throw std::runtime_error("BinaryReader::ReadSingle(): Error reading stream");
@@ -105,6 +149,17 @@ double BinaryReader::ReadDouble()
double result = NAN;
stream->Read((char*)&result, sizeof(double));
if (endianness != Endianness::Native)
{
double tmp;
char* dst = (char*)&tmp;
char* src = (char*)&result;
dst[7] = src[0]; dst[6] = src[1]; dst[5] = src[2]; dst[4] = src[3];
dst[3] = src[4]; dst[2] = src[5]; dst[1] = src[6]; dst[0] = src[7];
result = tmp;
}
if (std::isnan(result))
throw std::runtime_error("BinaryReader::ReadDouble(): Error reading stream");
+6
View File
@@ -8,6 +8,7 @@
#include "../Vec2f.h"
#include "../Vec3f.h"
#include "../Vec3s.h"
#include "BitConverter.h"
#include "Stream.h"
class BinaryReader
@@ -18,9 +19,13 @@ public:
void Close();
void SetEndianness(Endianness endianness);
Endianness GetEndianness() const;
void Seek(uint32_t offset, SeekOffsetType seekType);
uint32_t GetBaseAddress();
void Read(int32_t length);
void Read(char* buffer, int32_t length);
char ReadChar();
int8_t ReadByte();
@@ -41,4 +46,5 @@ public:
protected:
std::shared_ptr<Stream> stream;
Endianness endianness = Endianness::Native;
};
+43 -1
View File
@@ -10,6 +10,11 @@ BinaryWriter::BinaryWriter(std::shared_ptr<Stream> nStream)
stream = nStream;
}
void BinaryWriter::SetEndianness(Endianness endianness)
{
this->endianness = endianness;
}
void BinaryWriter::Close()
{
stream->Close();
@@ -47,16 +52,25 @@ void BinaryWriter::Write(uint8_t value)
void BinaryWriter::Write(int16_t value)
{
if (endianness != Endianness::Native)
value = BSWAP16(value);
stream->Write((char*)&value, sizeof(int16_t));
}
void BinaryWriter::Write(uint16_t value)
{
if (endianness != Endianness::Native)
value = BSWAP16(value);
stream->Write((char*)&value, sizeof(uint16_t));
}
void BinaryWriter::Write(int32_t value)
{
if (endianness != Endianness::Native)
value = BSWAP32(value);
stream->Write((char*)&value, sizeof(int32_t));
}
@@ -68,33 +82,61 @@ void BinaryWriter::Write(int32_t valueA, int32_t valueB)
void BinaryWriter::Write(uint32_t value)
{
if (endianness != Endianness::Native)
value = BSWAP32(value);
stream->Write((char*)&value, sizeof(uint32_t));
}
void BinaryWriter::Write(int64_t value)
{
if (endianness != Endianness::Native)
value = BSWAP64(value);
stream->Write((char*)&value, sizeof(int64_t));
}
void BinaryWriter::Write(uint64_t value)
{
if (endianness != Endianness::Native)
value = BSWAP64(value);
stream->Write((char*)&value, sizeof(uint64_t));
}
void BinaryWriter::Write(float value)
{
if (endianness != Endianness::Native)
{
float tmp;
char* dst = (char*)&tmp;
char* src = (char*)&value;
dst[3] = src[0]; dst[2] = src[1]; dst[1] = src[2]; dst[0] = src[3];
value = tmp;
}
stream->Write((char*)&value, sizeof(float));
}
void BinaryWriter::Write(double value)
{
if (endianness != Endianness::Native)
{
double tmp;
char* dst = (char*)&tmp;
char* src = (char*)&value;
dst[7] = src[0]; dst[6] = src[1]; dst[5] = src[2]; dst[4] = src[3];
dst[3] = src[4]; dst[2] = src[5]; dst[1] = src[6]; dst[0] = src[7];
value = tmp;
}
stream->Write((char*)&value, sizeof(double));
}
void BinaryWriter::Write(const std::string& str)
{
int strLen = str.size();
stream->Write((char*)&strLen, sizeof(int));
Write(strLen);
for (char c : str)
stream->WriteByte(c);
+4
View File
@@ -4,6 +4,7 @@
#include <memory>
#include <string>
#include <vector>
#include "BitConverter.h"
#include "Stream.h"
class BinaryWriter
@@ -12,6 +13,8 @@ public:
BinaryWriter(Stream* nStream);
BinaryWriter(std::shared_ptr<Stream> nStream);
void SetEndianness(Endianness endianness);
std::shared_ptr<Stream> GetStream();
uint64_t GetBaseAddress();
uint64_t GetLength();
@@ -34,4 +37,5 @@ public:
protected:
std::shared_ptr<Stream> stream;
Endianness endianness = Endianness::Native;
};
+22
View File
@@ -5,6 +5,28 @@
#include <vector>
#include <cstring>
#ifdef _MSC_VER
#define BSWAP16 _byteswap_ushort
#define BSWAP32 _byteswap_ulong
#define BSWAP64 _byteswap_uint64
#else
#define BSWAP16 __builtin_bswap16
#define BSWAP32 __builtin_bswap32
#define BSWAP64 __builtin_bswap64
#endif
enum class Endianness
{
Little = 0,
Big = 1,
#if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) || defined(__BIG_ENDIAN__)
Native = Big,
#else
Native = Little,
#endif
};
class BitConverter
{
public:
+3 -4
View File
@@ -1,8 +1,9 @@
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include "StringHelper.h"
#include <iostream>
#if __has_include(<filesystem>)
#include <filesystem>
@@ -12,8 +13,6 @@ namespace fs = std::filesystem;
namespace fs = std::experimental::filesystem;
#endif
#include "StringHelper.h"
#undef GetCurrentDirectory
#undef CreateDirectory
@@ -21,7 +20,7 @@ class Directory
{
public:
#ifndef PATH_HACK
static std::string GetCurrentDirectory() { return fs::current_path().u8string().c_str(); }
static std::string GetCurrentDirectory() { return fs::current_path().string(); }
#endif
static bool Exists(const fs::path& path) { return fs::exists(path); }
-7
View File
@@ -10,13 +10,6 @@ enum class SeekOffsetType
End
};
// TODO: Eventually account for endianess in binaryreader and binarywriter
enum class Endianess
{
Little = 0,
Big = 1,
};
class Stream
{
public:
+15 -15
View File
@@ -9,22 +9,18 @@
std::vector<std::string> StringHelper::Split(std::string s, const std::string& delimiter)
{
std::vector<std::string> result;
size_t pos_start = 0, pos_end, delim_len = delimiter.length();
std::string token;
std::vector<std::string> res;
size_t pos = 0;
std::string token;
while ((pos_end = s.find(delimiter, pos_start)) != std::string::npos) {
token = s.substr(pos_start, pos_end - pos_start);
pos_start = pos_end + delim_len;
res.push_back(token);
}
while ((pos = s.find(delimiter)) != std::string::npos)
{
token = s.substr(0, pos);
result.push_back(token);
s.erase(0, pos + delimiter.length());
}
if (s.length() != 0)
result.push_back(s);
return result;
res.push_back(s.substr(pos_start));
return res;
}
std::string StringHelper::Strip(std::string s, const std::string& delimiter)
@@ -68,7 +64,11 @@ void StringHelper::ReplaceOriginal(std::string& str, const std::string& from, co
bool StringHelper::StartsWith(const std::string& s, const std::string& input)
{
#if __cplusplus >= 202002L
return s.starts_with(input.c_str());
#else
return s.rfind(input, 0) == 0;
#endif
}
bool StringHelper::Contains(const std::string& s, const std::string& input)
@@ -127,4 +127,4 @@ bool StringHelper::IEquals(const std::string& a, const std::string& b)
{
return std::equal(a.begin(), a.end(), b.begin(), b.end(),
[](char a, char b) { return tolower(a) == tolower(b); });
}
}
-2
View File
@@ -1,7 +1,5 @@
#pragma once
#include <cstdint>
struct Vec3f
{
float x, y, z;
-6
View File
@@ -186,12 +186,6 @@
<ClCompile Include="Utils\MemoryStream.cpp" />
<ClCompile Include="Utils\StringHelper.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OTRGui\build\ZERO_CHECK.vcxproj">
<Project>{02d10590-9542-3f55-aaf8-6055677e2a2a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
+2 -2
View File
@@ -489,7 +489,7 @@ Current supported types are `Vec3s`, `Vec3i` or `Vec3f`.
- Example:
```xml
<Array Name="D_04002040" Count="24" Offset="0x2040">
<Array Name="gLinkPauseChildDekuShieldJointTable" Count="24" Offset="0x2040">
<Vector Type="s16" Dimensions="3" />
</Array>
```
@@ -497,7 +497,7 @@ Current supported types are `Vec3s`, `Vec3i` or `Vec3f`.
Will be extracted as:
```c
Vec3s D_04002040[24] = {
Vec3s gLinkPauseChildDekuShieldJointTable[24] = {
{ -37, 2346, 93 },
{ 0, 11995, 0 },
{ -16385, -305, -16333 },
-34
View File
@@ -1,34 +0,0 @@
#!/bin/bash
curl -sSfLO "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
chmod a+x linuxdeploy*.AppImage
curl -sSfL https://github.com$(curl https://github.com/probonopd/go-appimage/releases | grep "mkappimage-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2) -o mkappimage.AppImage
chmod a+x mkappimage.AppImage
mkdir -p AppDir/usr/bin
cp appimage/{soh.desktop,soh.sh} AppDir/
cp soh/macosx/sohIcon.png AppDir/soh.png
curl -sSfL https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt -o AppDir/usr/bin/gamecontrollerdb.txt
mkdir -p AppDir/usr/share/applications
mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps
mkdir -p AppDir/usr/lib
mv AppDir/soh.sh AppDir/usr/bin
cp -r build/* AppDir/usr/bin
chmod +x AppDir/usr/bin/{soh.elf,OTRGui,soh.sh}
cd AppDir && ln -s ./usr/bin/soh.sh ./AppRun && cd ..
export UPD_INFO="gh-releases-zsync|HarbourMasters|Shipwright-linux|develop|SOH-Linux.AppImage.zsync"
./linuxdeploy-x86_64.AppImage --appimage-extract-and-run \
--appdir=./AppDir/ \
-d ./AppDir/soh.desktop \
-i ./AppDir/soh.png \
-e ./AppDir/usr/bin/soh.elf
cd /soh
VERSION=Linux ./mkappimage.AppImage --appimage-extract-and-run ./AppDir # "SOH-Linux-x86_64.AppImage"
mv SOH-Linux-x86_64.AppImage SOH-Linux.AppImage # Keep Original Name
-148
View File
@@ -1,148 +0,0 @@
# Only used for standalone compilation, usually inherits these from the main makefile
CXX ?= g++
CC ?= gcc
AR := ar
FORMAT := clang-format-11
UNAME := $(shell uname)
ASAN ?= 0
DEBUG ?= 1
OPTFLAGS ?= -O0
LTO ?= 0
# flag to save whether the compiler being used is clang or gcc by checking CXX --version
CXX_IS_CLANG ?= $(shell $(CXX) --version | grep -c clang)
ifeq ($(CXX_IS_CLANG),1)
MXX := $(CXX)
else
MXX ?= clang++
endif
WARN := -Wall -Wextra -Werror \
-Wno-unused-variable \
-Wno-unused-parameter \
-Wno-unused-function \
-Wno-parentheses \
-Wno-narrowing \
-Wno-missing-field-initializers \
-Wno-error=multichar \
-Wno-unused-command-line-argument \
-Wno-delete-non-abstract-non-virtual-dtor \
-Wno-unused-private-field \
-Wno-deprecated-copy-with-user-provided-copy \
-Wno-deprecated-declarations \
-Wno-unknown-warning-option
CWARN :=
CXXWARN := -Wno-deprecated-enum-enum-conversion -Wno-deprecated-copy
ifneq ($(CXX_IS_CLANG),1)
WARN += -Wno-error=stringop-overflow
CXXWARN += -Wno-error=maybe-uninitialized
endif
CXXFLAGS := $(WARN) $(CXXWARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0
CFLAGS := $(WARN) $(CWARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0
CPPFLAGS := -MMD
MMFLAGS := -Wno-deprecated-declarations -ObjC++ -fobjc-weak -fobjc-arc
# if not using clang, ask clang to use gcc standard library
ifneq ($(CXX_IS_CLANG),1)
STD_ISYSTEM=$(shell ${CXX} -xc++ -E -v - < /dev/null 2>&1 | grep "> search starts here" -A2 | tail -n 2 | head -n 1)
CXX_ISYSTEM=$(shell ${CXX} -xc++ -E -v - < /dev/null 2>&1 | grep "> search starts here" -A2 | tail -n 2 | tail -n 1)
MMFLAGS += -stdlib++-isystem ${STD_ISYSTEM} -cxx-isystem ${CXX_ISYSTEM}
endif
ifeq ($(UNAME), Darwin) #APPLE
CPPFLAGS += $(shell pkg-config --cflags sdl2 glew) -framework OpenGL -framework Foundation
endif
ifneq ($(DEBUG),0)
CXXFLAGS += -g -D_DEBUG
CFLAGS += -g -D_DEBUG
endif
ifneq ($(ASAN),0)
CXXFLAGS += -fsanitize=address
CFLAGS += -fsanitize=address
endif
ifneq ($(LTO),0)
CXXFLAGS += -flto
CFLAGS += -flto
endif
SRC_DIRS := $(shell find . -type d -not -path "*build*")
CXX_FILES := \
$(shell find libultraship/Factories -name "*.cpp") \
$(shell find libultraship/Lib/Fast3D -name "*.cpp") \
$(shell find libultraship -maxdepth 1 -name "*.cpp") \
$(shell find libultraship/Lib/ImGui -maxdepth 1 -name "*.cpp") \
$(shell find libultraship/Lib/Mercury -maxdepth 1 -name "*.cpp") \
libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp \
libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp \
libultraship/Lib/StrHash64.cpp \
libultraship/Lib/tinyxml2/tinyxml2.cpp
C_FILES := \
libultraship/mixer.c \
libultraship/Lib/stb/stb_impl.c
MM_FILES := \
libultraship/OSXFolderManager.mm
FMT_FILES := $(shell find libultraship/ -type f \( -name "*.cpp" -o -name "*.h" \) -a -not -path "libultraship/Lib/*")
O_FILES := \
$(CXX_FILES:%.cpp=build/%.o) \
$(C_FILES:%.c=build/%.o)
ifeq ($(UNAME), Darwin) #APPLE
O_FILES += $(MM_FILES:%.mm=build/%.o)
endif
D_FILES := $(O_FILES:%.o=%.d)
LIB := libultraship.a
INC_DIRS := $(addprefix -I, \
../ZAPDTR/ZAPDUtils \
libultraship/Lib/Fast3D/U64 \
libultraship/Lib/spdlog \
libultraship/Lib/spdlog/include \
libultraship/Lib/ImGui \
libultraship/Lib/Mercury \
libultraship \
../StormLib/src \
)
# create build directories
$(shell mkdir -p $(SRC_DIRS:%=build/%))
all: $(LIB)
clean:
rm -rf build $(LIB)
format:
$(FORMAT) -i $(FMT_FILES)
.PHONY: all clean format
build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@
build/%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@
build/%.o: %.mm
$(MXX) $(MMFLAGS) $(CXXFLAGS) $(OPTFLAGS) $(INC_DIRS) -c $< -o $@
$(LIB): $(O_FILES)
$(AR) rcs $@ $^
-include $(D_FILES)
-29
View File
@@ -1,29 +0,0 @@
#include "OTRArchive.h"
void SaveTest()
{
auto archPtr = OtrLib::OTRArchive::CreateArchive("myarch.mpq");
auto arch = archPtr.get();
char data[] = "ABCDEFG!";
arch->AddFile("test.txt", (uintptr_t)data, sizeof(data));
}
void LoadTest()
{
std::shared_ptr<OtrLib::OTRArchive> archPtr(new OtrLib::OTRArchive("myarch.mpq"));
archPtr->LoadFile("(crcfile)");
int bp = 0;
}
int main()
{
LoadTest();
//SaveTest();
return 0;
}
Binary file not shown.
-152
View File
@@ -1,152 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{3c4a8151-48d1-4518-be1a-24016a5b800f}</ProjectGuid>
<RootNamespace>TestApp</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir)..\otrlib;$(ProjectDir)..\..\ZAPD\ZAPDUtils;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)x64\Debug;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>otrlib.lib;ZAPDUtils.lib;StormLibDUS.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
-64
View File
@@ -1,64 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30320.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libultraship", "libultraship\libultraship.vcxproj", "{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp", "TestApp\TestApp.vcxproj", "{3C4A8151-48D1-4518-BE1A-24016A5B800F}"
ProjectSection(ProjectDependencies) = postProject
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8} = {6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPD", "..\ZAPDTR\ZAPD\ZAPD.vcxproj", "{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZAPDUtils", "..\ZAPDTR\ZAPDUtils\ZAPDUtils.vcxproj", "{A2E01C3E-D647-45D1-9788-043DEBC1A908}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x64.ActiveCfg = Debug|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x64.Build.0 = Debug|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x86.ActiveCfg = Debug|Win32
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Debug|x86.Build.0 = Debug|Win32
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x64.ActiveCfg = Release|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x64.Build.0 = Release|x64
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x86.ActiveCfg = Release|Win32
{6DA9B521-65B7-41E2-8F8A-F0451CC18ED8}.Release|x86.Build.0 = Release|Win32
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Debug|x64.ActiveCfg = Debug|x64
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Debug|x64.Build.0 = Debug|x64
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Debug|x86.ActiveCfg = Debug|Win32
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Debug|x86.Build.0 = Debug|Win32
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Release|x64.ActiveCfg = Release|x64
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Release|x64.Build.0 = Release|x64
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Release|x86.ActiveCfg = Release|Win32
{3C4A8151-48D1-4518-BE1A-24016A5B800F}.Release|x86.Build.0 = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.ActiveCfg = Debug|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x64.Build.0 = Debug|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.ActiveCfg = Debug|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Debug|x86.Build.0 = Debug|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.ActiveCfg = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x64.Build.0 = Release|x64
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.ActiveCfg = Release|Win32
{B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36}.Release|x86.Build.0 = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.ActiveCfg = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x64.Build.0 = Debug|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.ActiveCfg = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Debug|x86.Build.0 = Debug|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.ActiveCfg = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x64.Build.0 = Release|x64
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.ActiveCfg = Release|Win32
{A2E01C3E-D647-45D1-9788-043DEBC1A908}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DCE19FF1-37C0-49CD-915A-DD695E15F00B}
EndGlobalSection
EndGlobal
+19 -9
View File
@@ -6,6 +6,10 @@
#include "Lib/StrHash64.h"
#include <filesystem>
#ifdef __SWITCH__
#include "SwitchImpl.h"
#endif
namespace Ship {
Archive::Archive(const std::string& MainPath, bool enableWriting) : Archive(MainPath, "", enableWriting)
{
@@ -35,7 +39,7 @@ namespace Ship {
std::copy(archivePath.begin(), archivePath.end(), t_filename);
bool success = SFileCreateArchive(t_filename, MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES | MPQ_CREATE_ARCHIVE_V2, fileCapacity, &archive->mainMPQ);
int error = GetLastError();
int32_t error = GetLastError();
delete[] t_filename;
@@ -46,7 +50,7 @@ namespace Ship {
}
else
{
SPDLOG_ERROR("({}) We tried to create an archive, but it has fallen and cannot get up.");
SPDLOG_ERROR("({}) We tried to create an archive, but it has fallen and cannot get up.", error);
return nullptr;
}
}
@@ -61,14 +65,8 @@ namespace Ship {
bool attempt = SFileOpenFileEx(mainMPQ, filePath.c_str(), 0, &fileHandle);
//if (!attempt)
//{
//std::string filePathAlt = StringHelper::Replace(filePath, "/", "\\");
//attempt |= SFileOpenFileEx(mainMPQ, filePathAlt.c_str(), 0, &fileHandle);
//}
if (!attempt) {
printf("({%i}) Failed to open file {%s} from mpq archive {%s}", GetLastError(), filePath.c_str(), MainPath.c_str());
SPDLOG_ERROR("({}) Failed to open file {} from mpq archive {}.", GetLastError(), filePath.c_str(), MainPath.c_str());
std::unique_lock<std::mutex> Lock(FileToLoad->FileLoadMutex);
FileToLoad->bHasLoadError = true;
return FileToLoad;
@@ -327,13 +325,21 @@ namespace Ship {
#ifdef _WIN32
std::wstring wfullPath = std::filesystem::absolute(MainPath).wstring();
#endif
#if defined(__SWITCH__)
std::string fullPath = MainPath;
#else
std::string fullPath = std::filesystem::absolute(MainPath).string();
#endif
#ifdef _WIN32
if (!SFileOpenArchive(wfullPath.c_str(), 0, enableWriting ? 0 : MPQ_OPEN_READ_ONLY, &mpqHandle)) {
#else
if (!SFileOpenArchive(fullPath.c_str(), 0, enableWriting ? 0 : MPQ_OPEN_READ_ONLY, &mpqHandle)) {
#endif
#ifdef __SWITCH__
Switch::ThrowMissingOTR(fullPath);
#endif
SPDLOG_ERROR("({}) Failed to open main mpq file {}.", GetLastError(), fullPath.c_str());
return false;
}
@@ -362,7 +368,11 @@ namespace Ship {
bool Archive::LoadPatchMPQ(const std::string& path) {
HANDLE patchHandle = NULL;
#if defined(__SWITCH__)
std::string fullPath = path;
#else
std::string fullPath = std::filesystem::absolute(path).string();
#endif
if (mpqHandles.contains(fullPath)) {
return true;
}
-1
View File
@@ -10,7 +10,6 @@
#include <string>
#include <vector>
#include "Resource.h"
//#include "Lib/StrHash64.h"
#include "StormLib.h"
+8
View File
@@ -14,3 +14,11 @@ namespace Ship {
constexpr int GetSampleRate() const { return 44100; }
};
}
#ifdef _WIN32
#include "WasapiAudioPlayer.h"
#elif defined(__linux)
#include "PulseAudioPlayer.h"
#endif
#include "SDLAudioPlayer.h"
+721
View File
@@ -0,0 +1,721 @@
set(PROJECT_NAME libultraship)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
enable_language(OBJCXX)
#set(CMAKE_OBJCXX_FLAGS "-Wno-deprecated-declarations -ObjC++")
endif()
################################################################################
# Source groups
################################################################################
set(Header_Files__Resources__Factories
"Factories/AnimationFactory.h"
"Factories/ArrayFactory.h"
"Factories/AudioFactory.h"
"Factories/BlobFactory.h"
"Factories/CollisionHeaderFactory.h"
"Factories/CutsceneFactory.h"
"Factories/DisplayListFactory.h"
"Factories/MaterialFactory.h"
"Factories/MtxFactory.h"
"Factories/PathFactory.h"
"Factories/PlayerAnimationFactory.h"
"Factories/ResourceLoader.h"
"Factories/SceneFactory.h"
"Factories/SkeletonFactory.h"
"Factories/SkeletonLimbFactory.h"
"Factories/TextFactory.h"
"Factories/TextureFactory.h"
"Factories/VtxFactory.h"
)
source_group("Header Files\\Resources\\Factories" FILES ${Header_Files__Resources__Factories})
set(Header_Files__Resources__Files
"Animation.h"
"Array.h"
"Audio.h"
"Blob.h"
"CollisionHeader.h"
"Cutscene.h"
"DisplayList.h"
"Material.h"
"Matrix.h"
"Model.h"
"Path.h"
"PlayerAnimation.h"
"Scene.h"
"Skeleton.h"
"SkeletonLimb.h"
"Text.h"
"Texture.h"
"Vertex.h"
)
source_group("Header Files\\Resources\\Files" FILES ${Header_Files__Resources__Files})
set(Source_Files__Audio
"abi.h"
"AudioPlayer.h"
"mixer.c"
"mixer.h"
"SDLAudioPlayer.cpp"
"SDLAudioPlayer.h"
)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(Source_Files__Audio__extra
"WasapiAudioPlayer.cpp"
"WasapiAudioPlayer.h"
)
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(Source_Files__Audio__extra
"PulseAudioPlayer.cpp"
"PulseAudioPlayer.h"
)
endif ()
source_group("Source Files\\Audio" FILES ${Source_Files__Audio} ${Source_Files__Audio__extra})
set(Source_Files__Controller
"ControlDeck.cpp"
"ControlDeck.h"
"Controller.cpp"
"Controller.h"
"ControllerAttachment.cpp"
"ControllerAttachment.h"
"InputEditor.cpp"
"InputEditor.h"
"KeyboardController.cpp"
"KeyboardController.h"
"UltraController.h"
"DummyController.cpp"
"DummyController.h"
)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
list(APPEND Source_Files__Controller
"SDLController.cpp"
"SDLController.h"
)
endif()
source_group("Source Files\\Controller" FILES ${Source_Files__Controller})
set(Source_Files__Controller__Attachment
"ControllerAttachment.cpp"
"ControllerAttachment.h"
"MemoryPack.cpp"
"MemoryPack.h"
"RumblePack.cpp"
"RumblePack.h"
)
source_group("Source Files\\Controller\\Attachment" FILES ${Source_Files__Controller__Attachment})
set(Source_Files__CustomImpl
"GameOverlay.cpp"
"GameOverlay.h"
"Console.cpp"
"Console.h"
"ImGuiImpl.cpp"
"ImGuiImpl.h"
)
source_group("Source Files\\CustomImpl" FILES ${Source_Files__CustomImpl})
set(Source_Files__CustomImpl__Hooks
"Hooks.cpp"
"Hooks.h"
)
source_group("Source Files\\CustomImpl\\Hooks" FILES ${Source_Files__CustomImpl__Hooks})
set(Source_Files__CustomImpl__Utils
"Utils.cpp"
"Utils.h"
)
source_group("Source Files\\CustomImpl\\Utils" FILES ${Source_Files__CustomImpl__Utils})
set(Source_Files__Globals
"Cvar.cpp"
"Cvar.h"
"LUSMacros.h"
"Window.cpp"
"Window.h"
)
source_group("Source Files\\Globals" FILES ${Source_Files__Globals})
set(Source_Files__Lib
"Lib/mINI/src/mini/ini.h"
"Lib/StrHash64.cpp"
"Lib/StrHash64.h"
"Lib/tinyxml2/tinyxml2.cpp"
"stox.cpp"
"stox.h"
)
source_group("Source Files\\Lib" FILES ${Source_Files__Lib})
set(Source_Files__Lib__Fast3D
"Lib/Fast3D/gfx_cc.cpp"
"Lib/Fast3D/gfx_cc.h"
"Lib/Fast3D/gfx_pc.cpp"
"Lib/Fast3D/gfx_pc.h"
"Lib/Fast3D/gfx_rendering_api.h"
"Lib/Fast3D/gfx_screen_config.h"
"Lib/Fast3D/gfx_window_manager_api.h"
)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
list(APPEND Source_Files__Lib__Fast3D
"Lib/Fast3D/gfx_opengl.cpp"
"Lib/Fast3D/gfx_opengl.h"
"Lib/Fast3D/gfx_sdl.h"
"Lib/Fast3D/gfx_sdl2.cpp"
)
endif()
source_group("Source Files\\Lib\\Fast3D" FILES ${Source_Files__Lib__Fast3D})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(Source_Files__Lib__Fast3D__extra
"Lib/Fast3D/gfx_direct3d11.cpp"
"Lib/Fast3D/gfx_direct3d11.h"
"Lib/Fast3D/gfx_direct3d12.cpp"
"Lib/Fast3D/gfx_direct3d12.h"
"Lib/Fast3D/gfx_direct3d12_guids.h"
"Lib/Fast3D/gfx_direct3d_common.cpp"
"Lib/Fast3D/gfx_direct3d_common.h"
"Lib/Fast3D/gfx_dxgi.cpp"
"Lib/Fast3D/gfx_dxgi.h"
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(Source_Files__Lib__Fast3D__extra
"Lib/Fast3D/gfx_glx.cpp"
"Lib/Fast3D/gfx_glx.h"
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(Source_Files__Lib__Fast3D__extra
"Lib/Fast3D/gfx_wiiu.cpp"
"Lib/Fast3D/gfx_wiiu.h"
"Lib/Fast3D/gfx_gx2.cpp"
"Lib/Fast3D/gfx_gx2.h"
"Lib/Fast3D/gx2_shader_gen.c"
"Lib/Fast3D/gx2_shader_gen.h"
)
endif()
source_group("Source Files\\Lib\\Fast3D\\extra" FILES ${Source_Files__Lib__Fast3D__extra})
set(Source_Files__Lib__ImGui
"Lib/ImGui/imconfig.h"
"Lib/ImGui/imgui.cpp"
"Lib/ImGui/imgui.h"
"Lib/ImGui/imgui_demo.cpp"
"Lib/ImGui/imgui_draw.cpp"
"Lib/ImGui/imgui_internal.h"
"Lib/ImGui/imgui_tables.cpp"
"Lib/ImGui/imgui_widgets.cpp"
"Lib/ImGui/imstb_rectpack.h"
"Lib/ImGui/imstb_textedit.h"
"Lib/ImGui/imstb_truetype.h"
)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
list(APPEND Source_Files__Lib__ImGui
"Lib/ImGui/backends/imgui_impl_opengl3.cpp"
"Lib/ImGui/backends/imgui_impl_opengl3.h"
"Lib/ImGui/backends/imgui_impl_sdl.cpp"
"Lib/ImGui/backends/imgui_impl_sdl.h"
)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(Source_Files__Lib__ImGui__Windows
"Lib/ImGui/backends/imgui_impl_dx11.cpp"
"Lib/ImGui/backends/imgui_impl_dx11.h"
"Lib/ImGui/backends/imgui_impl_win32.cpp"
"Lib/ImGui/backends/imgui_impl_win32.h"
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(Source_Files__Lib__ImGui__WiiU
"Lib/ImGui/backends/wiiu/imgui_impl_wiiu.cpp"
"Lib/ImGui/backends/wiiu/imgui_impl_wiiu.h"
"Lib/ImGui/backends/wiiu/imgui_impl_gx2.cpp"
"Lib/ImGui/backends/wiiu/imgui_impl_gx2.h"
)
endif ()
source_group("Source Files\\Lib\\ImGui" FILES
${Source_Files__Lib__ImGui}
${Source_Files__Lib__ImGui__Windows}
${Source_Files__Lib__ImGui__WiiU}
)
set(Source_Files__Lib__Mercury
"Lib/Mercury/Mercury.cpp"
"Lib/Mercury/Mercury.h"
)
source_group("Source Files\\Lib\\Mercury" FILES ${Source_Files__Lib__Mercury})
set(Source_Files__Lib__stb
"Lib/stb/stb_image.h"
"Lib/stb/stb_image_write.h"
"Lib/stb/stb_impl.c"
)
source_group("Source Files\\Lib\\stb" FILES ${Source_Files__Lib__stb})
set(Source_Files__Lib__dr_libs
"Lib/dr_libs/mp3.h"
"Lib/dr_libs/wav.h"
)
source_group("Source Files\\Lib\\dr_libs" FILES ${Source_Files__Lib__dr_libs})
set(Source_Files__Lib__tinyxml2
"Lib/tinyxml2/tinyxml2.h"
)
source_group("Source Files\\Lib\\tinyxml2" FILES ${Source_Files__Lib__tinyxml2})
set(Source_Files__Logging
"luslog.cpp"
"luslog.h"
)
source_group("Source Files\\Logging" FILES ${Source_Files__Logging})
set(Source_Files__Resources
"GameVersions.h"
"Resource.cpp"
"Resource.h"
"ResourceMgr.cpp"
"ResourceMgr.h"
)
source_group("Source Files\\Resources" FILES ${Source_Files__Resources})
set(Source_Files__Resources__Factories
"Factories/AnimationFactory.cpp"
"Factories/ArrayFactory.cpp"
"Factories/AudioFactory.cpp"
"Factories/BlobFactory.cpp"
"Factories/CollisionHeaderFactory.cpp"
"Factories/CutsceneFactory.cpp"
"Factories/DisplayListFactory.cpp"
"Factories/MaterialFactory.cpp"
"Factories/MtxFactory.cpp"
"Factories/PathFactory.cpp"
"Factories/PlayerAnimationFactory.cpp"
"Factories/ResourceLoader.cpp"
"Factories/SceneFactory.cpp"
"Factories/SkeletonFactory.cpp"
"Factories/SkeletonLimbFactory.cpp"
"Factories/TextFactory.cpp"
"Factories/TextureFactory.cpp"
"Factories/VtxFactory.cpp"
)
source_group("Source Files\\Resources\\Factories" FILES ${Source_Files__Resources__Factories})
set(Source_Files__Resources__Files
"Animation.cpp"
"Array.cpp"
"Audio.cpp"
"Blob.cpp"
"CollisionHeader.cpp"
"Cutscene.cpp"
"DisplayList.cpp"
"Material.cpp"
"Matrix.cpp"
"Model.cpp"
"Path.cpp"
"PlayerAnimation.cpp"
"Scene.cpp"
"Skeleton.cpp"
"SkeletonLimb.cpp"
"Text.cpp"
"Texture.cpp"
"Vertex.cpp"
)
source_group("Source Files\\Resources\\Files" FILES ${Source_Files__Resources__Files})
set(Source_Files__Resources__mpq
"Archive.cpp"
"Archive.h"
"File.cpp"
"File.h"
)
source_group("Source Files\\Resources\\mpq" FILES ${Source_Files__Resources__mpq})
set(Source_Files__Crash_Handler
"CrashHandler.cpp"
"CrashHandler.h"
)
source_group("Source Files\\Crash Handler" FILES ${Source_Files__Crash_Handler})
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(Source_Files__Darwin
"OSXFolderManager.mm"
"OSXFolderManager.h"
)
source_group("Source Files\\Darwin" FILES ${Source_Files__Darwin})
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
set(Source_Files__NintendoSwitch
"SwitchImpl.cpp"
"SwitchImpl.h"
)
source_group("Source Files\\NintendoSwitch" FILES ${Source_Files__NintendoSwitch})
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
set(Source_Files__CafeOS
"WiiUController.cpp"
"WiiUController.h"
"WiiUGamepad.cpp"
"WiiUGamepad.h"
"WiiUImpl.cpp"
"WiiUImpl.h"
)
source_group("Source Files\\CafeOS" FILES ${Source_Files__CafeOS})
endif()
set(ALL_FILES
${Header_Files__Resources__Factories}
${Header_Files__Resources__Files}
${Source_Files__Audio}
${Source_Files__Audio__extra}
${Source_Files__Controller}
${Source_Files__Controller__Attachment}
${Source_Files__CustomImpl}
${Source_Files__CustomImpl__Hooks}
${Source_Files__CustomImpl__Utils}
${Source_Files__Globals}
${Source_Files__Lib}
${Source_Files__Lib__Fast3D}
${Source_Files__Lib__Fast3D__extra}
${Source_Files__Lib__ImGui}
${Source_Files__Lib__ImGui__Windows}
${Source_Files__Lib__ImGui__WiiU}
${Source_Files__Lib__Mercury}
${Source_Files__Lib__stb}
${Source_Files__Lib__dr_libs}
${Source_Files__Lib__tinyxml2}
${Source_Files__Logging}
${Source_Files__Resources}
${Source_Files__Resources__Factories}
${Source_Files__Resources__Files}
${Source_Files__Resources__mpq}
${Source_Files__Crash_Handler}
${Source_Files__Darwin}
${Source_Files__NintendoSwitch}
${Source_Files__CafeOS}
)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} STATIC ${ALL_FILES})
if (NOT TARGET storm)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../StormLib ${CMAKE_BINARY_DIR}/StormLib EXCLUDE_FROM_ALL)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
set(ROOT_NAMESPACE libultraship)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(${PROJECT_NAME} PROPERTIES
VS_GLOBAL_KEYWORD "Win32Proj"
)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
set_target_properties(${PROJECT_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE "TRUE"
)
endif()
endif()
################################################################################
# MSVC runtime library
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR})
endif()
################################################################################
# Compile definitions
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"SPDLOG_ACTIVE_LEVEL=0;"
"WIN32;"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
"ENABLE_DX11;"
"ENABLE_OPENGL;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"SPDLOG_ACTIVE_LEVEL=0;"
"WIN32;"
"_CONSOLE;"
"_CRT_SECURE_NO_WARNINGS;"
"ENABLE_OPENGL;"
"ENABLE_DX11;"
"UNICODE;"
"_UNICODE"
STORMLIB_NO_AUTO_LINK
)
endif()
elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"SPDLOG_ACTIVE_LEVEL=3;"
"SPDLOG_NO_THREAD_ID;"
"SPDLOG_NO_TLS;"
"STBI_NO_THREAD_LOCALS;"
)
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang")
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"ENABLE_OPENGL;"
"SPDLOG_ACTIVE_LEVEL=0;"
)
endif()
################################################################################
# Compile and link options
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(SDL2)
find_package(GLEW)
find_package(X11)
if (NOT GLEW_FOUND)
include (FetchContent)
FetchContent_Declare(
glew
GIT_REPOSITORY https://github.com/Perlmint/glew-cmake.git
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../external/glew
)
FetchContent_MakeAvailable(glew)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external/glew/build/cmake ${CMAKE_BINARY_DIR}/glew EXCLUDE_FROM_ALL)
endif()
if (NOT GLEW_FOUND)
set(GLEW-INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/../../external/glew/include)
else()
set(GLEW-INCLUDE ${GLEW_INCLUDE_DIRS})
endif()
set(SDL2-INCLUDE ${SDL2_INCLUDE_DIRS})
elseif (CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS")
find_package(SDL2)
else()
find_package(SDL2)
find_package(GLEW)
set(GLEW-INCLUDE ${GLEW_INCLUDE_DIRS})
set(SDL2-INCLUDE ${SDL2_INCLUDE_DIRS})
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Lib/spdlog/include/
${CMAKE_CURRENT_SOURCE_DIR}/Lib/Fast3D/U64/
${CMAKE_CURRENT_SOURCE_DIR}/Lib/Fast3D/U64/PR
${SDL2-INCLUDE}
${GLEW-INCLUDE}
${SWITCH-INCLUDE}
${CMAKE_CURRENT_SOURCE_DIR}/Lib/ImGui/
${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/ZAPDUtils
${CMAKE_CURRENT_SOURCE_DIR}/../../StormLib/src
.
)
if(MSVC)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/Od;
/Oi-
>
$<$<CONFIG:Release>:
/std:c++latest;
/Oi;
/Gy
>
/permissive-;
/MP;
/sdl;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/Od;
/Oi-;
/W2
>
$<$<CONFIG:Release>:
/Oi;
/Gy;
/W3
>
/permissive-;
/MP;
/sdl;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
endif()
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/SUBSYSTEM:CONSOLE
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/OPT:ICF
>
/SUBSYSTEM:CONSOLE
)
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall
-Wextra
-Wno-error
-Wno-unused-variable
-Wno-unused-parameter
-Wno-unused-function
-Wno-parentheses
-Wno-narrowing
-Wno-missing-field-initializers
)
endif()
################################################################################
# Dependencies
################################################################################
# Link with other targets.
find_package(OpenGL QUIET)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(X11)
find_package(PulseAudio)
endif()
if (NOT GLEW_FOUND)
set(GLEW-LIB glew_s)
else()
set(GLEW-LIB GLEW::GLEW)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_link_libraries(${PROJECT_NAME}
"GLEW::GLEW;"
"opengl32;"
"storm;"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_link_libraries(${PROJECT_NAME}
"GLEW::GLEW;"
"opengl32;"
"storm;"
)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
find_package(SDL2)
find_package(GLEW)
find_package(OpenGL QUIET)
find_Library(OSX_FOUNDATION Foundation)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME}
"storm;"
SDL2::SDL2
GLEW::GLEW
${OPENGL_opengl_LIBRARY}
${CMAKE_DL_LIBS}
Threads::Threads
${OSX_FOUNDATION}
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME}
storm
SDL2::SDL2
Threads::Threads
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "CafeOS")
find_package(SDL2 REQUIRED)
target_link_libraries(${PROJECT_NAME}
storm
SDL2::SDL2-static
)
target_include_directories(${PROJECT_NAME} PRIVATE
${DEVKITPRO}/portlibs/wiiu/include/
)
else()
target_link_libraries(${PROJECT_NAME}
SDL2::SDL2
${PULSEAUDIO_LIBRARY}
${GLEW-LIB}
${OPENGL_glx_LIBRARY}
${OPENGL_opengl_LIBRARY}
${X11_LIBRARIES}
storm
)
endif()
+304 -218
View File
@@ -1,145 +1,133 @@
#include "Console.h"
#include <iostream>
#include <sstream>
#include "Cvar.h"
#include "GlobalCtx2.h"
#include "ImGuiImpl.h"
#include "Lib/ImGui/imgui.h"
#include "Utils/StringHelper.h"
#include "Lib/ImGui/imgui_internal.h"
#include "Utils.h"
#include <sstream>
std::map<ImGuiKey, std::string> Bindings;
std::map<ImGuiKey, std::string> BindingToggle;
static bool HelpCommand(const std::vector<std::string>&) {
INFO("SoH Commands:");
for(const auto& cmd : SohImGui::console->Commands) {
INFO("%s", (" - " + cmd.first).c_str());
namespace Ship {
std::string BuildUsage(const CommandEntry& entry) {
std::string usage;
for (const auto& arg : entry.arguments)
usage += StringHelper::Sprintf(arg.optional ? "[%s] " : "<%s> ", arg.info.c_str());
return usage;
}
return CMD_SUCCESS;
}
static bool ClearCommand(const std::vector<std::string>&) {
SohImGui::console->Log[SohImGui::console->selected_channel].clear();
return CMD_SUCCESS;
}
bool Console::HelpCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args) {
Console->SendInfoMessage("SoH Commands:");
for (const auto& cmd : Console->Commands) {
Console->SendInfoMessage(" - " + cmd.first);
}
return CMD_SUCCESS;
}
std::string toLowerCase(std::string in) {
std::string cpy(in);
std::transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower);
return cpy;
}
bool Console::ClearCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args) {
Console->ClearLogs(Console->GetCurrentChannel());
return CMD_SUCCESS;
}
static bool BindCommand(const std::vector<std::string>& args) {
if(args.size() > 2) {
const ImGuiIO* io = &ImGui::GetIO();;
for (size_t k = 0; k < std::size(io->KeysData); k++) {
std::string key(ImGui::GetKeyName(k));
bool Console::BindCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args) {
if (args.size() > 2) {
const ImGuiIO* io = &ImGui::GetIO();;
for (size_t k = 0; k < std::size(io->KeysData); k++) {
std::string key(ImGui::GetKeyName(k));
if(toLowerCase(args[1]) == toLowerCase(key)) {
std::vector<std::string> tmp;
const char* const delim = " ";
std::ostringstream imploded;
std::copy(args.begin() + 2, args.end(), std::ostream_iterator<std::string>(imploded, delim));
Bindings[k] = imploded.str();
INFO("Binding '%s' to %s", args[1].c_str(), Bindings[k].c_str());
break;
if (toLowerCase(args[1]) == toLowerCase(key)) {
std::vector<std::string> tmp;
const char* const delim = " ";
std::ostringstream imploded;
std::copy(args.begin() + 2, args.end(), std::ostream_iterator<std::string>(imploded, delim));
Console->Bindings[k] = imploded.str();
Console->SendInfoMessage("Binding '%s' to %s", args[1].c_str(), Console->Bindings[k].c_str());
break;
}
}
}
return CMD_SUCCESS;
}
bool Console::BindToggleCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args) {
if (args.size() > 2) {
const ImGuiIO* io = &ImGui::GetIO();;
for (size_t k = 0; k < std::size(io->KeysData); k++) {
std::string key(ImGui::GetKeyName(k));
if (toLowerCase(args[1]) == toLowerCase(key)) {
Console->BindingToggle[k] = args[2];
Console->SendInfoMessage("Binding toggle '%s' to %s", args[1].c_str(), Console->BindingToggle[k].c_str());
break;
}
}
}
return CMD_SUCCESS;
}
void Console::Init() {
this->inputBuffer = new char[MAX_BUFFER_SIZE];
strcpy(this->inputBuffer, "");
this->filterBuffer = new char[MAX_BUFFER_SIZE];
strcpy(this->filterBuffer, "");
AddCommand("help", { HelpCommand, "Shows all the commands" });
AddCommand("clear", { ClearCommand, "Clear the console history" });
AddCommand("bind", { BindCommand, "Binds key to commands" });
AddCommand("bind-toggle", { BindToggleCommand, "Bind key as a bool toggle" });
}
void Console::Update() {
for (auto [key, cmd] : Bindings) {
if (ImGui::IsKeyPressed(key)) Dispatch(cmd);
}
for (auto [key, var] : BindingToggle) {
if (ImGui::IsKeyPressed(key)) {
CVar* cvar = CVar_Get(var.c_str());
Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast<bool>(cvar->value.valueS32)));
}
}
}
return CMD_SUCCESS;
}
static bool BindToggleCommand(const std::vector<std::string>& args) {
if (args.size() > 2) {
const ImGuiIO* io = &ImGui::GetIO();;
for (size_t k = 0; k < std::size(io->KeysData); k++) {
std::string key(ImGui::GetKeyName(k));
if (toLowerCase(args[1]) == toLowerCase(key)) {
BindingToggle[k] = args[2];
INFO("Binding toggle '%s' to %s", args[1].c_str(), BindingToggle[k].c_str());
break;
}
void Console::Draw() {
if (!this->opened) {
CVar_SetS32("gConsoleEnabled", 0);
return;
}
}
return CMD_SUCCESS;
}
std::string BuildUsage(const CommandEntry& entry) {
std::string usage;
for (const auto& arg : entry.arguments)
usage += StringHelper::Sprintf(arg.optional ? "[%s] " : "<%s> ", arg.info.c_str());
return usage;
}
bool input_focus = false;
void Console::Init() {
this->InputBuffer = new char[MAX_BUFFER_SIZE];
strcpy(this->InputBuffer, "");
this->FilterBuffer = new char[MAX_BUFFER_SIZE];
strcpy(this->FilterBuffer, "");
this->Commands["help"] = { HelpCommand, "Shows all the commands" };
this->Commands["clear"] = { ClearCommand, "Clear the console history" };
this->Commands["bind"] = { BindCommand, "Binds key to commands" };
this->Commands["bind-toggle"] = { BindToggleCommand, "Bind key as a bool toggle" };
}
void Console::Update() {
for(auto [key, cmd] : Bindings) {
if (ImGui::IsKeyPressed(key)) Dispatch(cmd);
}
for (auto [key, var] : BindingToggle) {
if (ImGui::IsKeyPressed(key)) {
CVar* cvar = CVar_Get(var.c_str());
Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast<bool>(cvar->value.valueS32)));
}
}
}
extern "C" uint8_t __enableGameInput;
void Console::Draw() {
bool input_focus = false;
__enableGameInput = true;
if (!this->opened) return;
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoFocusOnAppearing);
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
ImGui::Begin("Console", &this->opened, ImGuiWindowFlags_NoFocusOnAppearing);
const ImVec2 pos = ImGui::GetWindowPos();
const ImVec2 size = ImGui::GetWindowSize();
__enableGameInput = !ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows);
// SohImGui::ShowCursor(ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows | ImGuiHoveredFlags_RectOnly), SohImGui::Dialogues::dConsole);
// Renders autocomplete window
if(this->OpenAutocomplete) {
if (this->openAutocomplete) {
ImGui::SetNextWindowSize(ImVec2(350, std::min(static_cast<int>(this->Autocomplete.size()), 3) * 20.f), ImGuiCond_Once);
ImGui::SetNextWindowPos(ImVec2(pos.x + 8, pos.y + size.y - 1));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(3, 3));
ImGui::Begin("##WndAutocomplete", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove );
ImGui::Begin("##WndAutocomplete", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove);
ImGui::BeginChild("AC_Child", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(.3f, .3f, .3f, 1.0f));
if (ImGui::BeginTable("AC_History", 1)) {
for (const auto &cmd : this->Autocomplete) {
std::string usage = BuildUsage(this->Commands[cmd]);
for (const auto& cmd : this->Autocomplete) {
std::string usage = BuildUsage(this->Commands[cmd]);
std::string preview = cmd + " - " + this->Commands[cmd].description;
std::string autocomplete = (usage == NULLSTR ? cmd : usage);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::Selectable(preview.c_str())) {
memset(this->InputBuffer, 0, MAX_BUFFER_SIZE);
memcpy(this->InputBuffer, autocomplete.c_str(), sizeof(char) * autocomplete.size());
this->OpenAutocomplete = false;
memset(this->inputBuffer, 0, MAX_BUFFER_SIZE);
memcpy(this->inputBuffer, autocomplete.c_str(), sizeof(char) * autocomplete.size());
this->openAutocomplete = false;
input_focus = true;
}
}
ImGui::EndTable();
}
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
this->OpenAutocomplete = false;
this->openAutocomplete = false;
}
ImGui::PopStyleColor();
ImGui::EndChild();
@@ -149,7 +137,7 @@ void Console::Draw() {
if (ImGui::BeginPopupContextWindow("Context Menu")) {
if (ImGui::MenuItem("Copy Text")) {
ImGui::SetClipboardText(this->Log[this->selected_channel][this->selectedId].text.c_str());
ImGui::SetClipboardText(this->Log[this->currentChannel][this->selectedId].text.c_str());
this->selectedId = -1;
}
ImGui::EndPopup();
@@ -159,172 +147,270 @@ void Console::Draw() {
}
// Renders top bar filters
if (ImGui::Button("Clear")) this->Log[this->selected_channel].clear();
ImGui::SameLine();
ImGui::SetNextItemWidth(150);
if (ImGui::BeginCombo("##channel", this->selected_channel.c_str())) {
for (const auto& channel : log_channels) {
const bool is_selected = (channel == std::string(this->selected_channel));
if (ImGui::Selectable(channel.c_str(), is_selected))
this->selected_channel = channel;
if (is_selected) ImGui::SetItemDefaultFocus();
if (ImGui::Button("Clear")) this->Log[this->currentChannel].clear();
if (CVar_GetS32("gSinkEnabled", 0)) {
ImGui::SameLine();
ImGui::SetNextItemWidth(150);
if (ImGui::BeginCombo("##channel", this->currentChannel.c_str())) {
for (const auto& channel : LogChannels) {
const bool is_selected = (channel == std::string(this->currentChannel));
if (ImGui::Selectable(channel.c_str(), is_selected))
this->currentChannel = channel;
if (is_selected) ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::EndCombo();
} else {
this->currentChannel = "Console";
}
ImGui::SameLine();
ImGui::SetNextItemWidth(150);
if (ImGui::BeginCombo("##level", this->level_filter.c_str())) {
for (const auto& filter : priority_filters) {
const bool is_selected = (filter == std::string(this->level_filter));
if (ImGui::Selectable(filter.c_str(), is_selected))
{
this->level_filter = filter;
if (is_selected) ImGui::SetItemDefaultFocus();
if (this->currentChannel != "Console") {
if (ImGui::BeginCombo("##level", spdlog::level::to_string_view(this->levelFilter).data())) {
for (const auto& priority_filter : PriorityFilters) {
const bool is_selected = priority_filter == this->levelFilter;
if (ImGui::Selectable(spdlog::level::to_string_view(priority_filter).data(), is_selected))
{
this->levelFilter = priority_filter;
if (is_selected) ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
ImGui::EndCombo();
} else {
this->levelFilter = spdlog::level::trace;
}
ImGui::SameLine();
ImGui::PushItemWidth(-1);
if (ImGui::InputTextWithHint("##input", "Filter", this->FilterBuffer, MAX_BUFFER_SIZE))this->filter = std::string(this->FilterBuffer);
if (ImGui::InputTextWithHint("##input", "Filter", this->filterBuffer, MAX_BUFFER_SIZE))this->filter = std::string(this->filterBuffer);
ImGui::PopItemWidth();
// Renders console history
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar);
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(.3f, .3f, .3f, 1.0f));
if (ImGui::BeginTable("History", 1)) {
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(.3f, .3f, .3f, 1.0f));
if (ImGui::BeginTable("History", 1)) {
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)))
if (this->selectedId < (int)this->Log.size() - 1) ++this->selectedId;
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)))
if (this->selectedId > 0) --this->selectedId;
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)))
if (this->selectedId < (int)this->Log.size() - 1)++this->selectedId;
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)))
if (this->selectedId > 0)--this->selectedId;
const std::vector<ConsoleLine> channel = this->Log[this->selected_channel];
for (int i = 0; i < static_cast<int>(channel.size()); i++) {
ConsoleLine line = channel[i];
if(!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue;
if(this->level_filter != NULLSTR && line.priority != (std::find(priority_filters.begin(), priority_filters.end(), this->level_filter) - priority_filters.begin()) - 1) continue;
std::string id = line.text + "##" + std::to_string(i);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
const bool is_selected = (this->selectedId == i) || std::find(this->selectedEntries.begin(), this->selectedEntries.end(), i) != this->selectedEntries.end();
ImGui::PushStyleColor(ImGuiCol_Text, this->priority_colors[line.priority]);
if (ImGui::Selectable(id.c_str(), is_selected)) {
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !is_selected)
this->selectedEntries.push_back(i);
const std::vector<ConsoleLine> channel = this->Log[this->currentChannel];
for (int i = 0; i < static_cast<int>(channel.size()); i++) {
ConsoleLine line = channel[i];
if (!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue;
if (this->levelFilter > line.priority) continue;
std::string id = line.text + "##" + std::to_string(i);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
const bool is_selected = (this->selectedId == i) || std::find(this->selectedEntries.begin(), this->selectedEntries.end(), i) != this->selectedEntries.end();
ImGui::PushStyleColor(ImGuiCol_Text, this->PriorityColours[line.priority]);
if (ImGui::Selectable(id.c_str(), is_selected)) {
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !is_selected)
this->selectedEntries.push_back(i);
else this->selectedEntries.clear();
this->selectedId = is_selected ? -1 : i;
}
ImGui::PopStyleColor();
if (is_selected) ImGui::SetItemDefaultFocus();
else this->selectedEntries.clear();
this->selectedId = is_selected ? -1 : i;
}
ImGui::EndTable();
ImGui::PopStyleColor();
if (is_selected) ImGui::SetItemDefaultFocus();
}
ImGui::PopStyleColor();
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
ImGui::SetScrollHereY(1.0f);
ImGui::EndTable();
}
ImGui::PopStyleColor();
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
ImGui::SetScrollHereY(1.0f);
ImGui::EndChild();
// Renders input textfield
constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit |
ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory;
ImGui::PushItemWidth(-1);
if(ImGui::InputTextWithHint("CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) {
input_focus = true;
if(this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ')
this->Dispatch(std::string(this->InputBuffer));
memset(this->InputBuffer, 0, MAX_BUFFER_SIZE);
}
if(this->CMDHint != NULLSTR) {
if (ImGui::IsItemFocused()) {
ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y + size.y));
ImGui::SameLine();
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(this->CMDHint.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
if (this->currentChannel == "Console") {
// Renders input textfield
constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit |
ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory;
#ifdef __WIIU__
ImGui::PushItemWidth(-53.0f * 2.0f);
#else
ImGui::PushItemWidth(-53.0f);
#endif
if (ImGui::InputTextWithHint("##CMDInput", ">", this->inputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) {
input_focus = true;
if (this->inputBuffer[0] != '\0' && this->inputBuffer[0] != ' ')
this->Dispatch(std::string(this->inputBuffer));
memset(this->inputBuffer, 0, MAX_BUFFER_SIZE);
}
if (this->cmdHint != NULLSTR) {
if (ImGui::IsItemFocused()) {
ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y + size.y));
ImGui::SameLine();
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(this->cmdHint.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}
ImGui::SameLine();
#ifdef __WIIU__
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 50 * 2.0f);
#else
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 50);
#endif
if (ImGui::Button("Submit") && !input_focus && this->inputBuffer[0] != '\0' && this->inputBuffer[0] != ' ') {
this->Dispatch(std::string(this->inputBuffer));
memset(this->inputBuffer, 0, MAX_BUFFER_SIZE);
}
ImGui::SetItemDefaultFocus();
if (input_focus) ImGui::SetKeyboardFocusHere(-1);
ImGui::PopItemWidth();
}
ImGui::SetItemDefaultFocus();
if (input_focus) ImGui::SetKeyboardFocusHere(-1);
ImGui::PopItemWidth();
ImGui::End();
}
void Console::Dispatch(const std::string& line) {
this->CMDHint = NULLSTR;
this->History.push_back(line);
this->Log[this->selected_channel].push_back({ "> " + line } );
const std::vector<std::string> cmd_args = StringHelper::Split(line, " ");
if (this->Commands.contains(cmd_args[0])) {
const CommandEntry entry = this->Commands[cmd_args[0]];
if(!entry.handler(cmd_args) && !entry.arguments.empty())
this->Log[this->selected_channel].push_back({ "[SOH] Usage: " + cmd_args[0] + " " + BuildUsage(entry), ERROR_LVL});
return;
ImGui::End();
}
this->Log[this->selected_channel].push_back({ "[SOH] Command not found", ERROR_LVL });
}
int Console::CallbackStub(ImGuiInputTextCallbackData* data) {
const auto instance = static_cast<Console*>(data->UserData);
const bool empty_history = instance->History.empty();
const int history_index = instance->HistoryIndex;
std::string history;
void Console::Dispatch(const std::string& line) {
this->cmdHint = NULLSTR;
this->History.push_back(line);
SendInfoMessage("> " + line);
const std::vector<std::string> cmd_args = StringHelper::Split(line, " ");
if (this->Commands.contains(cmd_args[0])) {
const CommandEntry entry = this->Commands[cmd_args[0]];
if (!entry.handler(shared_from_this(), cmd_args) && !entry.arguments.empty()) {
SendErrorMessage("[SOH] Usage: " + cmd_args[0] + " " + BuildUsage(entry));
}
switch(data->EventKey) {
return;
}
SendErrorMessage("[SOH] Command not found");
}
int Console::CallbackStub(ImGuiInputTextCallbackData* data) {
const auto instance = static_cast<Console*>(data->UserData);
const bool empty_history = instance->History.empty();
const int history_index = instance->historyIndex;
std::string history;
switch (data->EventKey) {
case ImGuiKey_Tab:
instance->Autocomplete.clear();
for (auto& [cmd, entry] : instance->Commands)
if (cmd.find(std::string(data->Buf)) != std::string::npos) instance->Autocomplete.push_back(cmd);
instance->OpenAutocomplete = !instance->Autocomplete.empty();
instance->CMDHint = NULLSTR;
instance->openAutocomplete = !instance->Autocomplete.empty();
instance->cmdHint = NULLSTR;
break;
case ImGuiKey_UpArrow:
if (empty_history) break;
if(history_index < static_cast<int>(instance->History.size()) - 1) instance->HistoryIndex += 1;
if (history_index < static_cast<int>(instance->History.size()) - 1) instance->historyIndex += 1;
data->DeleteChars(0, data->BufTextLen);
data->InsertChars(0, instance->History[instance->HistoryIndex].c_str());
instance->CMDHint = NULLSTR;
data->InsertChars(0, instance->History[instance->historyIndex].c_str());
instance->cmdHint = NULLSTR;
break;
case ImGuiKey_DownArrow:
if (empty_history) break;
if (history_index > -1) instance->HistoryIndex -= 1;
if (history_index > -1) instance->historyIndex -= 1;
data->DeleteChars(0, data->BufTextLen);
if(history_index >= 0)
if (history_index >= 0)
data->InsertChars(0, instance->History[history_index].c_str());
instance->CMDHint = NULLSTR;
instance->cmdHint = NULLSTR;
break;
case ImGuiKey_Escape:
instance->HistoryIndex = -1;
instance->historyIndex = -1;
data->DeleteChars(0, data->BufTextLen);
instance->OpenAutocomplete = false;
instance->CMDHint = NULLSTR;
instance->openAutocomplete = false;
instance->cmdHint = NULLSTR;
break;
default:
instance->OpenAutocomplete = false;
instance->openAutocomplete = false;
for (auto& [cmd, entry] : instance->Commands) {
const std::vector<std::string> cmd_args = StringHelper::Split(std::string(data->Buf), " ");
if (data->BufTextLen > 2 && !cmd_args.empty() && cmd.find(cmd_args[0]) != std::string::npos) {
instance->CMDHint = cmd + " " + BuildUsage(entry);
instance->cmdHint = cmd + " " + BuildUsage(entry);
break;
}
instance->CMDHint = NULLSTR;
instance->cmdHint = NULLSTR;
}
}
return 0;
}
return 0;
}
void Console::Append(const std::string& channel, Priority priority, const char* fmt, ...) {
char buf[1024];
va_list args;
va_start(args, fmt);
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf) - 1] = 0;
va_end(args);
this->Log[channel].push_back({ std::string(buf), priority });
}
void Console::Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, va_list args) {
char buf[2048];
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf) - 1] = 0;
this->Log[channel].push_back({ std::string(buf), priority });
}
void Console::Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
Append(channel, priority, fmt, args);
va_end(args);
}
void Console::SendInfoMessage(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
Append("Console", spdlog::level::info, fmt, args);
va_end(args);
}
void Console::SendErrorMessage(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
Append("Console", spdlog::level::err, fmt, args);
va_end(args);
}
void Console::SendInfoMessage(const std::string& str) {
Append("Console", spdlog::level::info, str.c_str());
}
void Console::SendErrorMessage(const std::string& str) {
Append("Console", spdlog::level::err, str.c_str());
}
void Console::ClearLogs(std::string channel) {
Log[channel].clear();
}
void Console::ClearLogs() {
for (auto [key, var] : Log) {
var.clear();
}
}
bool Console::HasCommand(const std::string& command) {
for (const auto& Command : Commands) {
if (Command.first == command) {
return true;
}
}
return false;
}
void Console::AddCommand(const std::string& command, CommandEntry entry) {
if (!HasCommand(command)) {
Commands[command] = entry;
}
}
std::string Console::GetCurrentChannel() {
return currentChannel;
}
bool Console::IsOpened() {
return opened;
}
void Console::Close() {
opened = false;
}
void Console::Open() {
opened = true;
}
}
+89 -69
View File
@@ -6,76 +6,96 @@
#include <functional>
#include "Lib/ImGui/imgui.h"
#include "spdlog/spdlog.h"
#define LOG(msg, ...) SohImGui::console->Append("Main", Priority::LOG_LVL, msg, ##__VA_ARGS__)
#define INFO(msg, ...) SohImGui::console->Append("Main", Priority::INFO_LVL, msg, ##__VA_ARGS__)
#define WARNING(msg, ...) SohImGui::console->Append("Main", Priority::WARNING_LVL, msg, ##__VA_ARGS__)
#define ERROR(msg, ...) SohImGui::console->Append("Main", Priority::ERROR_LVL, msg, ##__VA_ARGS__)
#define CMD_SUCCESS true
#define CMD_FAILED false
#define MAX_BUFFER_SIZE 255
#define NULLSTR "None"
namespace Ship {
#define CMD_SUCCESS true
#define CMD_FAILED false
#define MAX_BUFFER_SIZE 255
#define NULLSTR "None"
typedef std::function<bool(std::vector<std::string> args)> CommandHandler;
class Console;
typedef std::function<bool(std::shared_ptr<Console> Console, std::vector<std::string> args)> CommandHandler;
enum Priority {
INFO_LVL,
LOG_LVL,
WARNING_LVL,
ERROR_LVL
};
enum class ArgumentType {
TEXT, NUMBER, PLAYER_POS, PLAYER_ROT
};
struct CommandArgument {
std::string info;
ArgumentType type = ArgumentType::NUMBER;
bool optional = false;
};
struct CommandEntry {
CommandHandler handler;
std::string description;
std::vector<CommandArgument> arguments;
};
struct ConsoleLine {
std::string text;
Priority priority = Priority::INFO_LVL;
std::string channel = "Main";
};
class Console {
int selectedId = -1;
std::vector<int> selectedEntries;
std::string filter;
std::string level_filter = NULLSTR;
std::vector<std::string> log_channels = { "Main", "SoH Logging"};
std::vector<std::string> priority_filters = { "None", "Info", "Log", "Warning", "Error" };
std::vector<ImVec4> priority_colors = {
ImVec4(1.0f, 1.0f, 1.0f, 1.0f),
ImVec4(0.2f, 1.0f, 0.2f, 1.0f),
ImVec4(0.9f, 0.8f, 0.4f, 0.01f),
ImVec4(1.0f, 0.2f, 0.2f, 1.0f)
enum class ArgumentType {
TEXT, NUMBER, PLAYER_POS, PLAYER_ROT
};
public:
std::map<std::string, std::vector<ConsoleLine>> Log;
std::map<std::string, CommandEntry> Commands;
std::vector<std::string> Autocomplete;
std::vector<std::string> History;
std::string CMDHint = NULLSTR;
char* FilterBuffer = nullptr;
char* InputBuffer = nullptr;
bool OpenAutocomplete = false;
int HistoryIndex = -1;
std::string selected_channel = "Main";
bool opened = false;
void Init();
void Update();
void Draw();
void Append(const std::string& channel, Priority priority, const char* fmt, ...) IM_FMTARGS(4);
void Dispatch(const std::string& line);
static int CallbackStub(ImGuiInputTextCallbackData* data);
};
struct CommandArgument {
std::string info;
ArgumentType type = ArgumentType::NUMBER;
bool optional = false;
};
struct CommandEntry {
CommandHandler handler;
std::string description;
std::vector<CommandArgument> arguments;
};
struct ConsoleLine {
std::string text;
spdlog::level::level_enum priority = spdlog::level::info;
std::string channel = "Console";
};
class Console : public std::enable_shared_from_this<Console> {
private:
static int CallbackStub(ImGuiInputTextCallbackData* data);
static bool ClearCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args);
static bool HelpCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args);
static bool BindCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args);
static bool BindToggleCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args);
bool opened = false;
int selectedId = -1;
int historyIndex = -1;
std::vector<int> selectedEntries;
std::string filter;
std::string currentChannel = "Console";
bool openAutocomplete = false;
char* inputBuffer = nullptr;
char* filterBuffer = nullptr;
std::string cmdHint = NULLSTR;
spdlog::level::level_enum levelFilter = spdlog::level::trace;
std::vector<std::string> History;
std::vector<std::string> Autocomplete;
std::map<ImGuiKey, std::string> Bindings;
std::map<ImGuiKey, std::string> BindingToggle;
std::map<std::string, CommandEntry> Commands;
std::map<std::string, std::vector<ConsoleLine>> Log;
const std::vector<std::string> LogChannels = { "Console", "Logs" };
const std::vector<spdlog::level::level_enum> PriorityFilters = { spdlog::level::off, spdlog::level::critical, spdlog::level::err, spdlog::level::warn, spdlog::level::info, spdlog::level::debug, spdlog::level::trace };
const std::vector<ImVec4> PriorityColours = {
ImVec4(0.8f, 0.8f, 0.8f, 1.0f), // TRACE
ImVec4(0.9f, 0.9f, 0.9f, 1.0f), // DEBUG
ImVec4(1.0f, 1.0f, 1.0f, 1.0f), // INFO
ImVec4(1.0f, 0.875f, 0.125f, 1.0f), // WARN
ImVec4(0.65f, 0.18f, 0.25, 1.0f), // ERROR
ImVec4(0.95f, 0.11f, 0.25, 1.0f), // CRITICAL
ImVec4(0.0f, 0.0f, 0.0f, 0.0f) // OFF
};
protected:
void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, va_list args);
public:
void ClearLogs(std::string channel);
void ClearLogs();
void Init();
void Update();
void Draw();
void Dispatch(const std::string& line);
void SendInfoMessage(const char* fmt, ...);
void SendErrorMessage(const char* fmt, ...);
void SendInfoMessage(const std::string& str);
void SendErrorMessage(const std::string& str);
void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, ...);
bool HasCommand(const std::string& command);
void AddCommand(const std::string& command, CommandEntry entry);
std::string GetCurrentChannel();
bool IsOpened();
void Close();
void Open();
};
}
+269 -128
View File
@@ -2,145 +2,286 @@
#include "Window.h"
#include "Controller.h"
#include "DisconnectedController.h"
#include "DummyController.h"
#include <Utils/StringHelper.h>
#include "Cvar.h"
#include "Lib/ImGui/imgui.h"
#ifndef __WIIU__
#include "KeyboardController.h"
#include "SDLController.h"
#include <Utils/StringHelper.h>
#else
#include "WiiUGamepad.h"
#include "WiiUController.h"
#endif
uint8_t* controllerBits;
namespace Ship {
void Ship::ControlDeck::Init(uint8_t* bits) {
ScanPhysicalDevices();
controllerBits = bits;
}
void ControlDeck::Init(uint8_t* bits) {
ScanPhysicalDevices();
controllerBits = bits;
}
void Ship::ControlDeck::ScanPhysicalDevices() {
void ControlDeck::ScanPhysicalDevices() {
virtualDevices.clear();
physicalDevices.clear();
virtualDevices.clear();
physicalDevices.clear();
for (int i = 0; i < SDL_NumJoysticks(); i++) {
if (SDL_IsGameController(i)) {
auto sdl = std::make_shared<SDLController>(i);
sdl->Open();
physicalDevices.push_back(sdl);
#ifndef __WIIU__
for (int32_t i = 0; i < SDL_NumJoysticks(); i++) {
if (SDL_IsGameController(i)) {
auto sdl = std::make_shared<SDLController>(i);
sdl->Open();
physicalDevices.push_back(sdl);
}
}
physicalDevices.push_back(std::make_shared<DummyController>("Auto", "Auto", true));
physicalDevices.push_back(std::make_shared<KeyboardController>());
#else
physicalDevices.push_back(std::make_shared<DummyController>("Auto", "Auto", true));
auto gamepad = std::make_shared<Ship::WiiUGamepad>();
gamepad->Open();
physicalDevices.push_back(gamepad);
for (int32_t i = 0; i < 4; i++) {
auto controller = std::make_shared<Ship::WiiUController>((WPADChan) i);
controller->Open();
physicalDevices.push_back(controller);
}
#endif
physicalDevices.push_back(std::make_shared<DummyController>("Disconnected", "None", false));
for (const auto device : physicalDevices) {
for (int32_t i = 0; i < MAXCONTROLLERS; i++) {
device->CreateDefaultBinding(i);
}
}
for (int32_t i = 0; i < MAXCONTROLLERS; i++) {
virtualDevices.push_back(i == 0 ? 0 : static_cast<int>(physicalDevices.size()) - 1);
}
LoadControllerSettings();
}
void ControlDeck::SetPhysicalDevice(int32_t slot, int32_t deviceSlot) {
const std::shared_ptr<Controller> backend = physicalDevices[deviceSlot];
virtualDevices[slot] = deviceSlot;
*controllerBits |= (backend->Connected()) << slot;
}
void ControlDeck::WriteToPad(OSContPad* pad) const {
for (size_t i = 0; i < virtualDevices.size(); i++) {
const std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
// If the controller backend is "Auto" we need to get the real device
// we search for the real device to read input from it
if (backend->GetGuid() == "Auto") {
for (const auto& device : physicalDevices) {
if(ShouldBlockGameInput(device->GetGuid())) {
device->Read(nullptr, i);
continue;
}
device->Read(&pad[i], i);
}
continue;
}
if(ShouldBlockGameInput(backend->GetGuid())) {
backend->Read(nullptr, i);
continue;
}
backend->Read(&pad[i], i);
}
}
physicalDevices.push_back(std::make_shared<KeyboardController>());
physicalDevices.push_back(std::make_shared<DisconnectedController>());
#define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), virtualSlot, __VA_ARGS__)
for (const auto& device : physicalDevices) {
for (int i = 0; i < MAXCONTROLLERS; i++) {
device->CreateDefaultBinding(i);
}
}
void ControlDeck::LoadControllerSettings() {
std::shared_ptr<Mercury> Config = Window::GetInstance()->GetConfig();
for (int i = 0; i < MAXCONTROLLERS; i++) {
virtualDevices.push_back(i == 0 ? 0 : static_cast<int>(physicalDevices.size()) - 1);
}
for (auto const& val : Config->rjson["Controllers"]["Deck"].items()) {
int32_t slot = std::stoi(val.key().substr(5));
LoadControllerSettings();
}
void Ship::ControlDeck::SetPhysicalDevice(int slot, int deviceSlot) {
const std::shared_ptr<Controller> backend = physicalDevices[deviceSlot];
virtualDevices[slot] = deviceSlot;
*controllerBits |= (backend->Connected()) << slot;
}
void Ship::ControlDeck::WriteToPad(OSContPad* pad) const {
for (size_t i = 0; i < virtualDevices.size(); i++) {
physicalDevices[virtualDevices[i]]->Read(&pad[i], i);
}
}
#define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), slot, __VA_ARGS__)
void Ship::ControlDeck::LoadControllerSettings() {
std::shared_ptr<Mercury> Config = GlobalCtx2::GetInstance()->GetConfig();
for (auto const& val : Config->rjson["Controllers"]["Deck"].items()) {
int slot = std::stoi(val.key().substr(5));
for (size_t dev = 0; dev < physicalDevices.size(); dev++) {
std::string guid = physicalDevices[dev]->GetGuid();
if(guid != val.value()) continue;
virtualDevices[slot] = dev;
}
}
for (size_t i = 0; i < virtualDevices.size(); i++) {
std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid());
}
for (const auto& device : physicalDevices) {
std::string guid = device->GetGuid();
for (int slot = 0; slot < MAXCONTROLLERS; slot++) {
if (!(Config->rjson["Controllers"].contains(guid) && Config->rjson["Controllers"][guid].contains(StringHelper::Sprintf("Slot_%d", slot)))) continue;
auto& profile = device->profiles[slot];
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)];
profile.Mappings.clear();
profile.Thresholds.clear();
profile.UseRumble = Config->getBool(NESTED("Rumble.Enabled", ""));
profile.RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", ""));
profile.UseGyro = Config->getBool(NESTED("Gyro.Enabled", ""));
for (auto const& val : rawProfile["Thresholds"].items()) {
profile.Thresholds[static_cast<ControllerThresholds>(std::stoi(val.key()))] = val.value();
}
for (auto const& val : rawProfile["Mappings"].items()) {
device->SetButtonMapping(slot, std::stoi(val.key().substr(4)), val.value());
}
}
}
}
void Ship::ControlDeck::SaveControllerSettings() {
std::shared_ptr<Mercury> Config = GlobalCtx2::GetInstance()->GetConfig();
for (size_t i = 0; i < virtualDevices.size(); i++) {
std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid());
}
for (const auto& device : physicalDevices) {
int slot = 0;
std::string guid = device->GetGuid();
for (const auto& profile : device->profiles) {
if (!device->Connected()) continue;
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)];
Config->setBool(NESTED("Rumble.Enabled", ""), profile.UseRumble);
Config->setFloat(NESTED("Rumble.Strength", ""), profile.RumbleStrength);
Config->setBool(NESTED("Gyro.Enabled", ""), profile.UseGyro);
for (auto const& val : rawProfile["Mappings"].items()) {
Config->setInt(NESTED("Mappings.%s", val.key().c_str()), -1);
}
for (auto const& [key, val] : profile.Thresholds) {
Config->setFloat(NESTED("Thresholds.%d", key), val);
}
for (auto const& [key, val] : profile.Mappings) {
Config->setInt(NESTED("Mappings.BTN_%d", val), key);
}
slot++;
}
}
Config->save();
for (size_t dev = 0; dev < physicalDevices.size(); dev++) {
std::string guid = physicalDevices[dev]->GetGuid();
if (guid != val.value()) continue;
virtualDevices[slot] = dev;
}
}
for (size_t i = 0; i < virtualDevices.size(); i++) {
std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid());
}
for (const auto device : physicalDevices) {
std::string guid = device->GetGuid();
for (int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
if (!(Config->rjson["Controllers"].contains(guid) && Config->rjson["Controllers"][guid].contains(StringHelper::Sprintf("Slot_%d", virtualSlot)))) continue;
auto profile = device->getProfile(virtualSlot);
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", virtualSlot)];
profile->Mappings.clear();
profile->AxisDeadzones.clear();
profile->AxisDeadzones.clear();
profile->GyroData.clear();
profile->Version = Config->getInt(NESTED("Version", ""), DEVICE_PROFILE_VERSION_V0);
switch (profile->Version) {
case DEVICE_PROFILE_VERSION_V0:
// Load up defaults for the things we can't load.
device->CreateDefaultBinding(virtualSlot);
profile->UseRumble = Config->getBool(NESTED("Rumble.Enabled", ""));
profile->RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", ""));
profile->UseGyro = Config->getBool(NESTED("Gyro.Enabled", ""));
for (auto const& val : rawProfile["Mappings"].items()) {
device->SetButtonMapping(virtualSlot, std::stoi(val.key().substr(4)), val.value());
}
break;
case DEVICE_PROFILE_VERSION_V1:
profile->UseRumble = Config->getBool(NESTED("Rumble.Enabled", ""));
profile->RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", ""));
profile->UseGyro = Config->getBool(NESTED("Gyro.Enabled", ""));
for (auto const& val : rawProfile["AxisDeadzones"].items()) {
profile->AxisDeadzones[std::stoi(val.key())] = val.value();
}
for (auto const& val : rawProfile["AxisMinimumPress"].items()) {
profile->AxisMinimumPress[std::stoi(val.key())] = val.value();
}
for (auto const& val : rawProfile["GyroData"].items()) {
profile->GyroData[std::stoi(val.key())] = val.value();
}
for (auto const& val : rawProfile["Mappings"].items()) {
device->SetButtonMapping(virtualSlot, std::stoi(val.key().substr(4)), val.value());
}
break;
// Version is invalid.
default:
device->CreateDefaultBinding(virtualSlot);
break;
}
}
}
}
void ControlDeck::SaveControllerSettings() {
std::shared_ptr<Mercury> Config = Window::GetInstance()->GetConfig();
for (size_t i = 0; i < virtualDevices.size(); i++) {
std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid());
}
for (const auto& device : physicalDevices) {
int32_t virtualSlot = 0;
std::string guid = device->GetGuid();
for (int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
auto profile = device->getProfile(virtualSlot);
if (!device->Connected()) continue;
auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", virtualSlot)];
Config->setInt(NESTED("Version", ""), profile->Version);
Config->setBool(NESTED("Rumble.Enabled", ""), profile->UseRumble);
Config->setFloat(NESTED("Rumble.Strength", ""), profile->RumbleStrength);
Config->setBool(NESTED("Gyro.Enabled", ""), profile->UseGyro);
for (auto const& val : rawProfile["Mappings"].items()) {
Config->setInt(NESTED("Mappings.%s", val.key().c_str()), -1);
}
for (auto const& [key, val] : profile->AxisDeadzones) {
Config->setFloat(NESTED("AxisDeadzones.%d", key), val);
}
for (auto const& [key, val] : profile->AxisMinimumPress) {
Config->setFloat(NESTED("AxisMinimumPress.%d", key), val);
}
for (auto const& [key, val] : profile->GyroData) {
Config->setFloat(NESTED("GyroData.%d", key), val);
}
for (auto const& [key, val] : profile->Mappings) {
Config->setInt(NESTED("Mappings.BTN_%d", val), key);
}
virtualSlot++;
}
}
Config->save();
}
std::shared_ptr<Controller> ControlDeck::GetPhysicalDevice(int32_t deviceSlot) {
return physicalDevices[deviceSlot];
}
size_t ControlDeck::GetNumPhysicalDevices() {
return physicalDevices.size();
}
int32_t ControlDeck::GetVirtualDevice(int32_t slot) {
return virtualDevices[slot];
}
size_t ControlDeck::GetNumVirtualDevices() {
return virtualDevices.size();
}
std::shared_ptr<Controller> ControlDeck::GetPhysicalDeviceFromVirtualSlot(int32_t slot) {
return GetPhysicalDevice(GetVirtualDevice(slot));
}
uint8_t* ControlDeck::GetControllerBits() {
return controllerBits;
}
void ControlDeck::BlockGameInput() {
shouldBlockGameInput = true;
}
void ControlDeck::UnblockGameInput() {
shouldBlockGameInput = false;
}
bool ControlDeck::ShouldBlockGameInput(std::string inputDeviceGuid) const {
// We block controller input if F1 menu is open and control navigation is on.
// This is because we don't want controller inputs to affect the game
bool shouldBlockControllerInput = CVar_GetS32("gOpenMenuBar", 0) && CVar_GetS32("gControlNav", 0);
// We block keyboard input if you're currently typing into a textfield.
// This is because we don't want your keyboard typing to affect the game.
ImGuiIO io = ImGui::GetIO();
bool shouldBlockKeyboardInput = io.WantCaptureKeyboard;
bool inputDeviceIsKeyboard = inputDeviceGuid == "Keyboard";
return shouldBlockGameInput || (inputDeviceIsKeyboard ? shouldBlockKeyboardInput : shouldBlockControllerInput);
}
}
+16 -4
View File
@@ -2,19 +2,31 @@
#include "Controller.h"
#include <vector>
#include <string>
#include "Lib/Mercury/Mercury.h"
namespace Ship {
class ControlDeck {
public:
std::vector<int> virtualDevices;
std::vector<std::shared_ptr<Controller>> physicalDevices = {};
void Init(uint8_t* controllerBits);
void ScanPhysicalDevices();
void WriteToPad(OSContPad* pad) const;
void LoadControllerSettings();
void SaveControllerSettings();
void SetPhysicalDevice(int slot, int deviceSlot);
void SetPhysicalDevice(int32_t slot, int32_t deviceSlot);
std::shared_ptr<Controller> GetPhysicalDevice(int32_t deviceSlot);
std::shared_ptr<Controller> GetPhysicalDeviceFromVirtualSlot(int32_t slot);
size_t GetNumPhysicalDevices();
int32_t GetVirtualDevice(int32_t slot);
size_t GetNumVirtualDevices();
uint8_t* GetControllerBits();
void BlockGameInput();
void UnblockGameInput();
bool ShouldBlockGameInput(std::string inputDeviceGuid) const;
private:
std::vector<int32_t> virtualDevices = {};
std::vector<std::shared_ptr<Controller>> physicalDevices = {};
uint8_t* controllerBits = nullptr;
bool shouldBlockGameInput = false;
};
}
+101 -35
View File
@@ -1,6 +1,7 @@
#include "Controller.h"
#include <memory>
#include <algorithm>
#include "Cvar.h"
#if __APPLE__
#include <SDL_events.h>
#else
@@ -9,72 +10,137 @@
namespace Ship {
Controller::Controller() : isRumbling(false), wStickX(0), wStickY(0), wGyroX(0), wGyroY(0), dwPressedButtons(0){
Controller::Controller() : isRumbling(false) {
Attachment = nullptr;
profiles.resize(MAXCONTROLLERS);
for(int slot = 0; slot < MAXCONTROLLERS; slot++) {
dwPressedButtons.push_back(0);
for(int32_t virtualSlot = 0; virtualSlot < MAXCONTROLLERS; virtualSlot++) {
profiles[virtualSlot] = std::make_shared<DeviceProfile>();
ButtonData[virtualSlot] = std::make_shared<Buttons>();
}
}
void Controller::Read(OSContPad* pad, int32_t slot) {
ReadFromSource(slot);
void Controller::Read(OSContPad* pad, int32_t virtualSlot) {
ReadFromSource(virtualSlot);
OSContPad padToBuffer = { 0 };
#ifndef __WIIU__
SDL_PumpEvents();
#endif
// Button Inputs
pad->button |= dwPressedButtons[slot] & 0xFFFF;
padToBuffer.button |= getPressedButtons(virtualSlot) & 0xFFFF;
// Stick Inputs
if (wStickX == 0) {
if (dwPressedButtons[slot] & BTN_STICKLEFT) {
pad->stick_x = -128;
} else if (dwPressedButtons[slot] & BTN_STICKRIGHT) {
pad->stick_x = 127;
if (getLeftStickX(virtualSlot) == 0) {
if (getPressedButtons(virtualSlot) & BTN_STICKLEFT) {
padToBuffer.stick_x = -128;
} else if (getPressedButtons(virtualSlot) & BTN_STICKRIGHT) {
padToBuffer.stick_x = 127;
}
} else {
pad->stick_x = wStickX;
padToBuffer.stick_x = getLeftStickX(virtualSlot);
}
if (wStickY == 0) {
if (dwPressedButtons[slot] & BTN_STICKDOWN) {
pad->stick_y = -128;
} else if (dwPressedButtons[slot] & BTN_STICKUP) {
pad->stick_y = 127;
if (getLeftStickY(virtualSlot) == 0) {
if (getPressedButtons(virtualSlot) & BTN_STICKDOWN) {
padToBuffer.stick_y = -128;
} else if (getPressedButtons(virtualSlot) & BTN_STICKUP) {
padToBuffer.stick_y = 127;
}
} else {
pad->stick_y = wStickY;
padToBuffer.stick_y = getLeftStickY(virtualSlot);
}
// Stick Inputs
if (wCamX == 0) {
if (dwPressedButtons[slot] & BTN_VSTICKLEFT) {
pad->cam_x = -128 * 10.0f;
} else if (dwPressedButtons[slot] & BTN_VSTICKRIGHT) {
pad->cam_x = 127 * 10.0f;
if (getRightStickX(virtualSlot) == 0) {
if (getPressedButtons(virtualSlot) & BTN_VSTICKLEFT) {
padToBuffer.right_stick_x = -128;
} else if (getPressedButtons(virtualSlot) & BTN_VSTICKRIGHT) {
padToBuffer.right_stick_x = 127;
}
} else {
pad->cam_x = wCamX;
padToBuffer.right_stick_x = getRightStickX(virtualSlot);
}
if (wCamY == 0) {
if (dwPressedButtons[slot] & BTN_VSTICKDOWN) {
pad->cam_y = -128 * 10.0f;
} else if (dwPressedButtons[slot] & BTN_VSTICKUP) {
pad->cam_y = 127 * 10.0f;
if (getRightStickY(virtualSlot) == 0) {
if (getPressedButtons(virtualSlot) & BTN_VSTICKDOWN) {
padToBuffer.right_stick_y = -128;
} else if (getPressedButtons(virtualSlot) & BTN_VSTICKUP) {
padToBuffer.right_stick_y = 127;
}
} else {
pad->cam_y = wCamY;
padToBuffer.right_stick_y = getRightStickY(virtualSlot);
}
// Gyro
pad->gyro_x = wGyroX;
pad->gyro_y = wGyroY;
padToBuffer.gyro_x = getGyroX(virtualSlot);
padToBuffer.gyro_y = getGyroY(virtualSlot);
padBuffer.push_front(padToBuffer);
if (pad != nullptr) {
auto &padFromBuffer = padBuffer[std::min(padBuffer.size() - 1, (size_t)CVar_GetS32("gSimulatedInputLag", 0))];
pad->button |= padFromBuffer.button;
if (pad->stick_x == 0) pad->stick_x = padFromBuffer.stick_x;
if (pad->stick_y == 0) pad->stick_y = padFromBuffer.stick_y;
if (pad->gyro_x == 0) pad->gyro_x = padFromBuffer.gyro_x;
if (pad->gyro_y == 0) pad->gyro_y = padFromBuffer.gyro_y;
if (pad->right_stick_x == 0) pad->right_stick_x = padFromBuffer.right_stick_x;
if (pad->right_stick_y == 0) pad->right_stick_y = padFromBuffer.right_stick_y;
}
while (padBuffer.size() > 6) {
padBuffer.pop_back();
}
}
void Controller::SetButtonMapping(int slot, int32_t n64Button, int32_t dwScancode) {
std::map<int32_t, int32_t>& Mappings = profiles[slot].Mappings;
void Controller::SetButtonMapping(int32_t virtualSlot, int32_t n64Button, int32_t dwScancode) {
std::map<int32_t, int32_t>& Mappings = getProfile(virtualSlot)->Mappings;
std::erase_if(Mappings, [n64Button](const std::pair<int32_t, int32_t>& bin) { return bin.second == n64Button; });
Mappings[dwScancode] = n64Button;
}
int8_t& Controller::getLeftStickX(int32_t virtualSlot) {
return ButtonData[virtualSlot]->leftStickX;
}
int8_t& Controller::getLeftStickY(int32_t virtualSlot) {
return ButtonData[virtualSlot]->leftStickY;
}
int8_t& Controller::getRightStickX(int32_t virtualSlot) {
return ButtonData[virtualSlot]->rightStickX;
}
int8_t& Controller::getRightStickY(int32_t virtualSlot) {
return ButtonData[virtualSlot]->rightStickY;
}
int32_t& Controller::getPressedButtons(int32_t virtualSlot) {
return ButtonData[virtualSlot]->pressedButtons;
}
float& Controller::getGyroX(int32_t virtualSlot) {
return ButtonData[virtualSlot]->gyroX;
}
float& Controller::getGyroY(int32_t virtualSlot) {
return ButtonData[virtualSlot]->gyroY;
}
std::shared_ptr<DeviceProfile> Controller::getProfile(int32_t virtualSlot) {
return profiles[virtualSlot];
}
std::shared_ptr<ControllerAttachment> Controller::GetAttachment() {
return Attachment;
}
bool Controller::IsRumbling() {
return isRumbling;
}
std::string Controller::GetGuid() {
return GUID;
}
}
+58 -49
View File
@@ -3,79 +3,88 @@
#include <map>
#include <memory>
#include <string>
#include "stdint.h"
#include <cstdint>
#include <queue>
#include "UltraController.h"
#include "ControllerAttachment.h"
#include <vector>
#include <unordered_map>
#define EXTENDED_SCANCODE_BIT (1 << 8)
#define AXIS_SCANCODE_BIT (1 << 9)
namespace Ship {
enum ControllerThresholds {
LEFT_STICK = 1,
RIGHT_STICK = 2,
LEFT_TRIGGER = 3,
RIGHT_TRIGGER = 4,
DRIFT_X = 5,
DRIFT_Y = 6,
SENSITIVITY = 7,
GYRO_SENSITIVITY = 8
enum GyroData {
DRIFT_X,
DRIFT_Y,
GYRO_SENSITIVITY
};
enum DeviceProfileVersion {
DEVICE_PROFILE_VERSION_V0 = 0,
DEVICE_PROFILE_VERSION_V1 = 1
};
#define DEVICE_PROFILE_CURRENT_VERSION DEVICE_PROFILE_VERSION_V1
struct DeviceProfile {
int32_t Version = 0;
bool UseRumble = false;
bool UseGyro = false;
float RumbleStrength = 1.0f;
std::unordered_map<ControllerThresholds, float> Thresholds;
std::unordered_map<int32_t, float> AxisDeadzones;
std::unordered_map<int32_t, float> AxisMinimumPress;
std::unordered_map<int32_t, float> GyroData;
std::map<int32_t, int32_t> Mappings;
};
class Controller {
public:
virtual ~Controller() = default;
Controller();
void Read(OSContPad* pad, int32_t slot);
virtual void ReadFromSource(int32_t slot) = 0;
virtual void WriteToSource(int32_t slot, ControllerCallback* controller) = 0;
virtual bool Connected() const = 0;
virtual bool CanRumble() const = 0;
virtual bool CanGyro() const = 0;
virtual void CreateDefaultBinding(int32_t slot) = 0;
bool isRumbling;
std::vector<DeviceProfile> profiles;
virtual void ClearRawPress() = 0;
virtual int32_t ReadRawPress() = 0;
void SetButtonMapping(int slot, int32_t n64Button, int32_t dwScancode);
std::shared_ptr<ControllerAttachment> GetAttachment() { return Attachment; }
std::string GetGuid() { return GUID; }
virtual const char* GetButtonName(int slot, int n64Button) = 0;
virtual const char* GetControllerName() = 0;
int8_t wStickX;
int8_t wStickY;
float wGyroX;
float wGyroY;
float wCamX;
float wCamY;
public:
virtual ~Controller() = default;
Controller();
virtual void ReadFromSource(int32_t virtualSlot) = 0;
virtual void WriteToSource(int32_t virtualSlot, ControllerCallback* controller) = 0;
virtual bool Connected() const = 0;
virtual bool CanRumble() const = 0;
virtual bool CanGyro() const = 0;
virtual void CreateDefaultBinding(int32_t virtualSlot) = 0;
virtual void ClearRawPress() = 0;
virtual int32_t ReadRawPress() = 0;
virtual const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) = 0;
virtual const std::string GetControllerName() = 0;
void Read(OSContPad* pad, int32_t virtualSlot);
void SetButtonMapping(int32_t virtualSlot, int32_t n64Button, int32_t dwScancode);
std::shared_ptr<ControllerAttachment> GetAttachment();
std::shared_ptr<DeviceProfile> getProfile(int32_t virtualSlot);
int8_t& getLeftStickX(int32_t virtualSlot);
int8_t& getLeftStickY(int32_t virtualSlot);
int8_t& getRightStickX(int32_t virtualSlot);
int8_t& getRightStickY(int32_t virtualSlot);
int32_t& getPressedButtons(int32_t virtualSlot);
float& getGyroX(int32_t virtualSlot);
float& getGyroY(int32_t virtualSlot);
bool IsRumbling();
std::string GetGuid();
protected:
std::vector<int32_t> dwPressedButtons;
std::shared_ptr<ControllerAttachment> Attachment;
std::string GUID;
bool isRumbling;
void LoadBinding();
private:
std::shared_ptr<ControllerAttachment> Attachment;
};
struct Buttons {
int32_t pressedButtons = 0;
int8_t leftStickX = 0;
int8_t leftStickY = 0;
int8_t rightStickX = 0;
int8_t rightStickY = 0;
float gyroX = 0.0f;
float gyroY = 0.0f;
};
struct ControllerEntry {
uint8_t* controllerBits;
Controller* entryIO;
std::unordered_map<int32_t, std::shared_ptr<DeviceProfile>> profiles;
std::unordered_map<int32_t, std::shared_ptr<Buttons>> ButtonData = {};
std::deque<OSContPad> padBuffer;
};
}
+472
View File
@@ -0,0 +1,472 @@
#include "spdlog/spdlog.h"
#include "Utils/StringHelper.h"
#include "CrashHandler.h"
#include "Window.h"
#include "ResourceMgr.h"
#include "GameVersions.h"
#include "Cvar.h"
#define WRITE_VAR_LINE(buff, len, varName, varValue) \
append_str(buff, len, varName); \
append_line(buff, len, varValue);
#define WRITE_VAR(buff, len, varName, varValue) \
append_str(buff, len, varName); \
append_str(buff, len, varValue);
extern "C" void DeinitOTR(void);
static CrashHandlerCallback sCallbackFunc = nullptr;
static const char* GetGameVersionString() {
if(Ship::Window::GetInstance()->GetResourceManager()->IsRunning()) {
uint32_t version = Ship::Window::GetInstance()->GetResourceManager()->GetGameVersion();
switch (version) {
case OOT_NTSC_10:
return "NTSC 1.0";
case OOT_NTSC_11:
return "NTSC 1.1";
case OOT_NTSC_12:
return "NTSC 1.2";
case OOT_PAL_10:
return "PAL 1.0";
case OOT_PAL_11:
return "PAL 1.1";
case OOT_NTSC_JP_GC_CE:
return "NTSC JP_GC_CE";
case OOT_NTSC_JP_GC:
return "NTSC_JP_GC";
case OOT_NTSC_US_GC:
return "NTSC_US_GC";
case OOT_PAL_GC:
return "PAL_GC";
case OOT_NTSC_JP_MQ:
return "NTSC_JP_MQ";
case OOT_NTSC_US_MQ:
return "NTSC_US_MQ";
case OOT_PAL_MQ:
return "PAL_MQ";
case OOT_PAL_GC_DBG1:
return "DBG_1";
case OOT_PAL_GC_DBG2:
return "DBG_2";
case OOT_PAL_GC_MQ_DBG:
return "MQ_DBG";
case OOT_IQUE_TW:
return "IQUE_TW";
case OOT_IQUE_CN:
return "IQUE_CN";
case OOT_UNKNOWN:
return "UNKNOWN";
}
}
return "ResourceMGR not ready";
}
static void append_str(char* buf, size_t* len, const char* str) {
while (*str != '\0')
buf[(*len)++] = *str++;
}
static void append_line(char* buf, size_t* len, const char* str) {
while (*str != '\0')
buf[(*len)++] = *str++;
buf[(*len)++] = '\n';
}
/**
* @brief Prints common data relevant to the crash
*
* @param buffer
*/
static void CrashHandler_PrintCommon(char* buffer, size_t* curBufferPos) {
WRITE_VAR_LINE(buffer, curBufferPos, "OTR Generated with: ", GetGameVersionString());
if (sCallbackFunc != nullptr) {
sCallbackFunc(buffer, curBufferPos);
}
SPDLOG_CRITICAL(buffer);
}
#if defined(__linux__)
#include <csignal>
#include <cstdio>
#include <cxxabi.h> // for __cxa_demangle
#include <dlfcn.h> // for dladdr
#include <execinfo.h>
#include <unistd.h>
#include <SDL.h>
static void PrintRegisters(ucontext_t* ctx, char* buffer, size_t* pos) {
char regbuffer[128];
append_line(buffer, pos, "Registers:");
#if defined(__x86_64__)
snprintf(regbuffer, std::size(regbuffer), "RAX: 0x%016llX", ctx->uc_mcontext.gregs[REG_RAX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RDI: 0x%016llX", ctx->uc_mcontext.gregs[REG_RDI]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RSI: 0x%016llX", ctx->uc_mcontext.gregs[REG_RSI]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RDX: 0x%016llX", ctx->uc_mcontext.gregs[REG_RDX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RCX: 0x%016llX", ctx->uc_mcontext.gregs[REG_RCX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R8: 0x%016llX", ctx->uc_mcontext.gregs[REG_R8]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R9: 0x%016llX", ctx->uc_mcontext.gregs[REG_R9]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R10: 0x%016llX", ctx->uc_mcontext.gregs[REG_R10]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R11: 0x%016llX", ctx->uc_mcontext.gregs[REG_R11]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RSP: 0x%016llX", ctx->uc_mcontext.gregs[REG_RSP]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RBX: 0x%016llX", ctx->uc_mcontext.gregs[REG_RBX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RBP: 0x%016llX", ctx->uc_mcontext.gregs[REG_RBP]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R12: 0x%016llX", ctx->uc_mcontext.gregs[REG_R12]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R13: 0x%016llX", ctx->uc_mcontext.gregs[REG_R13]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R14: 0x%016llX", ctx->uc_mcontext.gregs[REG_R14]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "R15: 0x%016llX", ctx->uc_mcontext.gregs[REG_R15]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "RIP: 0x%016llX", ctx->uc_mcontext.gregs[REG_RIP]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer), "EFL: 0x%016llX", ctx->uc_mcontext.gregs[REG_EFL]);
append_line(buffer, pos, regbuffer);
#else
snprintf(regbuffer, std::size(regbuffer),"EDI: 0x%08lX", ctx->uc_mcontext.gregs[REG_EDI]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"ESI: 0x%08lX", ctx->uc_mcontext.gregs[REG_ESI]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"EBP: 0x%08lX", ctx->uc_mcontext.gregs[REG_EBP]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"ESP: 0x%08lX", ctx->uc_mcontext.gregs[REG_ESP]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"EBX: 0x%08lX", ctx->uc_mcontext.gregs[REG_EBX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"EDX: 0x%08lX", ctx->uc_mcontext.gregs[REG_EDX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"ECX: 0x%08lX", ctx->uc_mcontext.gregs[REG_ECX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"EAX: 0x%08lX", ctx->uc_mcontext.gregs[REG_EAX]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"EIP: 0x%08lX", ctx->uc_mcontext.gregs[REG_EIP]);
append_line(buffer, pos, regbuffer);
snprintf(regbuffer, std::size(regbuffer),"EFL: 0x%08lX", ctx->uc_mcontext.gregs[REG_EFL]);
append_line(buffer, pos, regbuffer);
#endif
}
static void ErrorHandler(int sig, siginfo_t* sigInfo, void* data) {
constexpr size_t MAX_BUFF_SIZE = 32768;
size_t curBufferPos = 0;
char buffer[MAX_BUFF_SIZE];
char intToCharBuffer[16];
std::array<void*, 4096> arr;
ucontext_t* ctx = static_cast<ucontext_t*>(data);
constexpr size_t nMaxFrames = arr.size();
size_t size = backtrace(arr.data(), nMaxFrames);
char** symbols = backtrace_symbols(arr.data(), nMaxFrames);
snprintf(intToCharBuffer, sizeof(intToCharBuffer), "Signal: %i", sig);
append_line(buffer, &curBufferPos, intToCharBuffer);
switch (sig) {
case SIGILL:
append_line(buffer, &curBufferPos, "ILLEGAL INSTRUCTION");
break;
case SIGABRT:
append_line(buffer, &curBufferPos, "ABORT");
break;
case SIGFPE:
append_line(buffer, &curBufferPos, "ERRONEUS ARITHEMETIC OPERATION");
break;
case SIGSEGV:
append_line(buffer, &curBufferPos, "INVALID ACCESS TO STORAGE");
break;
}
PrintRegisters(ctx, buffer, &curBufferPos);
append_line(buffer, &curBufferPos, "Traceback:");
for (size_t i = 1; i < size; i++) {
Dl_info info;
int gotAddress = dladdr(arr[i], &info);
std::string functionName(symbols[i]);
if (gotAddress != 0 && info.dli_sname != nullptr) {
FILE* pipe;
int32_t status;
char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
const char* nameFound = info.dli_sname;
if (status == 0) {
nameFound = demangled;
}
#if 0
char command[256];
char addrLine[128];
snprintf(command, sizeof(command), "addr2line -e soh.elf %s + 0x%lX", nameFound, (uintptr_t)arr[i] - (uintptr_t)info.dli_saddr);
pipe = popen(command, "r");
fgets(addrLine, 128, pipe);
#endif
functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound,
(char*)arr[i] - (char*)info.dli_saddr);
free(demangled);
}
snprintf(intToCharBuffer, sizeof(intToCharBuffer), "%i ", (int)i);
WRITE_VAR_LINE(buffer, &curBufferPos, intToCharBuffer, functionName.c_str());
}
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SoH has crashed", "SoH Has crashed. Please upload the logs to the support channel in discord.", nullptr);
free(symbols);
CrashHandler_PrintCommon(buffer, &curBufferPos);
DeinitOTR();
Ship::Window::GetInstance()->GetLogger()->flush();
spdlog::shutdown();
exit(1);
}
static void ShutdownHandler(int sig, siginfo_t* sigInfo, void* data) {
DeinitOTR();
exit(1);
}
#elif _WIN32
#if defined(_WIN32) && !defined(_WIN64)
#define WINDOWS_32_BIT
#endif
static void PrintRegisters(CONTEXT* ctx, char* buffer, size_t* pos) {
append_line(buffer, pos, "Registers: ");
char regBuff[25];
#if defined(_M_AMD64)
sprintf_s(regBuff, std::size(regBuff), "RAX: 0x%016llX", ctx->Rax);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RCX: 0x%016llX", ctx->Rcx);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RDX: 0x%016llX", ctx->Rdx);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RBX: 0x%016llX", ctx->Rbx);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RSP: 0x%016llX", ctx->Rsp);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RBP: 0x%016llX", ctx->Rbp);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RSI: 0x%016llX", ctx->Rsi);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RDI: 0x%016llX", ctx->Rdi);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "R9: 0x%016llX", ctx->R9);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "R10: 0x%016llX", ctx->R10);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "R11: 0x%016llX", ctx->R11);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "R12: 0x%016llX", ctx->R12);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "R13: 0x%016llX", ctx->R13);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "R14: 0x%016llX", ctx->R14);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "R15: 0x%016llX", ctx->R15);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "RIP: 0x%016llX", ctx->Rip);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "EFLAGS: 0x%08lX", ctx->EFlags);
append_line(buffer, pos, regBuff);
#elif WINDOWS_32_BIT
sprintf_s(regBuff, std::size(regBuff), "EDI: 0x%08lX", ctx->Edi);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "ESI: 0x%08lX", ctx->Esi);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "EBX: 0x%08lX", ctx->Ebx);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "ECX: 0x%08lX", ctx->Ecx);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "EAX: 0x%08lX", ctx->Eax);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "EBP: 0x%08lX", ctx->Ebp);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "ESP: 0x%08lX", ctx->Esp);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "EFLAGS: 0x%08lX", ctx->EFlags);
append_line(buffer, pos, regBuff);
sprintf_s(regBuff, std::size(regBuff), "EIP: 0x%08lX", ctx->Eip);
append_line(buffer, pos, regBuff);
#endif
}
static void printStack(CONTEXT* ctx, char* logBuffer, size_t* pos) {
BOOL result;
HANDLE process;
HANDLE thread;
HMODULE hModule;
ULONG frame;
DWORD64 displacement;
DWORD disp;
#if defined(_M_AMD64)
STACKFRAME64 stack;
memset(&stack, 0, sizeof(STACKFRAME64));
#elif WINDOWS_32_BIT
STACKFRAME stack;
memset(&stack, 0, sizeof(STACKFRAME));
stack.AddrPC.Offset = (*ctx).Eip;
stack.AddrPC.Mode = AddrModeFlat;
stack.AddrStack.Offset = (*ctx).Esp;
stack.AddrStack.Mode = AddrModeFlat;
stack.AddrFrame.Offset = (*ctx).Ebp;
stack.AddrFrame.Mode = AddrModeFlat;
#endif
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME + sizeof(TCHAR)];
char module[512];
PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
CONTEXT ctx2;
memcpy(&ctx2, ctx, sizeof(CONTEXT));
PrintRegisters(&ctx2, logBuffer, pos);
process = GetCurrentProcess();
thread = GetCurrentThread();
SymSetOptions(SYMOPT_NO_IMAGE_SEARCH | SYMOPT_IGNORE_IMAGEDIR);
SymInitialize(process, "debug", true);
constexpr DWORD machineType =
#if defined(_M_AMD64)
IMAGE_FILE_MACHINE_AMD64;
#elif WINDOWS_32_BIT
IMAGE_FILE_MACHINE_I386;
#endif
displacement = 0;
for (frame = 0;; frame++) {
result = StackWalk(machineType, process, thread, &stack, &ctx2, nullptr, SymFunctionTableAccess,
SymGetModuleBase, nullptr);
if (!result) {
break;
}
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
symbol->MaxNameLen = MAX_SYM_NAME;
SymFromAddr(process, (ULONG64)stack.AddrPC.Offset, &displacement, symbol);
#if defined(_M_AMD64)
IMAGEHLP_LINE64 line;
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
#elif WINDOWS_32_BIT
IMAGEHLP_LINE line;
line.SizeOfStruct = sizeof(IMAGEHLP_LINE);
#endif
if (SymGetLineFromAddr(process, stack.AddrPC.Offset, &disp, &line)) {
char lineNumberStr[16];
sprintf_s(lineNumberStr, sizeof(lineNumberStr), "Line: %d", line.LineNumber);
append_str(logBuffer, pos, symbol->Name); append_str(logBuffer, pos, " in "); append_str(logBuffer, pos, line.FileName); append_line(logBuffer, pos, lineNumberStr);
//SPDLOG_CRITICAL("{} in {}: line: {}: ", symbol->Name, line.FileName, line.LineNumber);
}
else {
char addrString[20];
sprintf_s(addrString, std::size(addrString), "0x%016llX", symbol->Address);
WRITE_VAR(logBuffer, pos, "At ", symbol->Name); WRITE_VAR_LINE(logBuffer, pos, "Addr: ", addrString);
//SPDLOG_CRITICAL("at {}, addr 0x{}", symbol->Name, addrString);
hModule = nullptr;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCTSTR)(stack.AddrPC.Offset), &hModule);
if (hModule != nullptr) {
GetModuleFileNameA(hModule, module, sizeof(module));
}
WRITE_VAR_LINE(logBuffer, pos, "In: ", module);
// SPDLOG_CRITICAL("In {}", module);
}
}
CrashHandler_PrintCommon(logBuffer, pos);
Ship::Window::GetInstance()->GetLogger()->flush();
spdlog::shutdown();
DeinitOTR();
}
extern "C" LONG seh_filter(struct _EXCEPTION_POINTERS* ex) {
char exceptionString[20];
constexpr size_t MAX_BUFF_SIZE = 32768;
size_t curBufferPos = 0;
char buffer[MAX_BUFF_SIZE];
snprintf(exceptionString, std::size(exceptionString), "0x%x", ex->ExceptionRecord->ExceptionCode);
WRITE_VAR_LINE(buffer, &curBufferPos, "Exception: ", exceptionString);
printStack(ex->ContextRecord, buffer, &curBufferPos);
MessageBoxA(nullptr, "SoH Has crashed. Please upload the logs to the support channel in discord.", "Crash", MB_OK | MB_ICONERROR);
CrashHandler_PrintCommon(buffer, &curBufferPos);
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
extern "C" void CrashHandler_Init(CrashHandlerCallback callback) {
#if defined(__linux__)
struct sigaction action;
struct sigaction shutdownAction;
action.sa_flags = SA_SIGINFO;
action.sa_sigaction = ErrorHandler;
sigaction(SIGILL, &action, nullptr);
sigaction(SIGABRT, &action, nullptr);
sigaction(SIGFPE, &action, nullptr);
sigaction(SIGSEGV, &action, nullptr);
shutdownAction.sa_flags = SA_SIGINFO;
shutdownAction.sa_sigaction = ShutdownHandler;
sigaction(SIGINT, &shutdownAction, nullptr);
sigaction(SIGTERM, &shutdownAction, nullptr);
sigaction(SIGQUIT, &shutdownAction, nullptr);
sigaction(SIGKILL, &shutdownAction, nullptr);
#elif _WIN32
SetUnhandledExceptionFilter(seh_filter);
#endif
sCallbackFunc = callback;
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef CRASH_HANDLER_H
#define CRASH_HANDLER_H
#include <stddef.h>
typedef void(*CrashHandlerCallback)(char*, size_t*);
#ifdef __cplusplus
extern "C" {
#endif
void CrashHandler_Init(CrashHandlerCallback callback);
#ifdef __cplusplus
}
#endif
#ifdef _WIN32
#include <windows.h>
#include <DbgHelp.h>
#include <inttypes.h>
#include <excpt.h>
#ifdef __cplusplus
extern "C" {
#endif
LONG seh_filter(struct _EXCEPTION_POINTERS* ex);
#ifdef __cplusplus
}
#endif
#pragma comment(lib, "Dbghelp.lib")
#endif
#endif // CRASH_HANDLER_H
+506 -5
View File
@@ -1,4 +1,103 @@
#include "Cutscene.h"
#include "spdlog/spdlog.h"
enum class CutsceneCommands
{
Cmd00 = 0x0000,
SetCameraPos = 0x0001,
SetCameraFocus = 0x0002,
SpecialAction = 0x0003,
SetLighting = 0x0004,
SetCameraPosLink = 0x0005,
SetCameraFocusLink = 0x0006,
Cmd07 = 0x0007,
Cmd08 = 0x0008,
Cmd09 = 0x0009,
Unknown = 0x001A,
Textbox = 0x0013,
SetActorAction0 = 0x000A,
SetActorAction1 = 0x000F,
SetActorAction2 = 0x000E,
SetActorAction3 = 0x0019,
SetActorAction4 = 0x001D,
SetActorAction5 = 0x001E,
SetActorAction6 = 0x002C,
SetActorAction7 = 0x001F,
SetActorAction8 = 0x0031,
SetActorAction9 = 0x003E,
SetActorAction10 = 0x008F,
SetSceneTransFX = 0x002D,
Nop = 0x000B,
PlayBGM = 0x0056,
StopBGM = 0x0057,
FadeBGM = 0x007C,
SetTime = 0x008C,
Terminator = 0x03E8,
End = 0xFFFF,
Error = 0xFEAF,
};
static inline uint32_t read_CMD_BBBB(BinaryReader* reader)
{
uint32_t v;
reader->Read((char*)&v, sizeof(uint32_t));
return v;
}
static inline uint32_t read_CMD_BBH(BinaryReader* reader)
{
uint32_t v;
reader->Read((char*)&v, sizeof(uint32_t));
// swap the half word to match endianness
if (reader->GetEndianness() != Endianness::Native)
{
uint8_t* b = (uint8_t*)&v;
uint8_t tmp = b[2];
b[2] = b[3];
b[3] = tmp;
}
return v;
}
static inline uint32_t read_CMD_HBB(BinaryReader* reader)
{
uint32_t v;
reader->Read((char*)&v, sizeof(uint32_t));
// swap the half word to match endianness
if (reader->GetEndianness() != Endianness::Native)
{
uint8_t* b = (uint8_t*)&v;
uint8_t tmp = b[0];
b[0] = b[1];
b[1] = tmp;
}
return v;
}
static inline uint32_t read_CMD_HH(BinaryReader* reader)
{
uint32_t v;
reader->Read((char*)&v, sizeof(uint32_t));
// swap the half words to match endianness
if (reader->GetEndianness() != Endianness::Native)
{
uint8_t* b = (uint8_t*)&v;
uint8_t tmp = b[0];
b[0] = b[1];
b[1] = tmp;
tmp = b[2];
b[2] = b[3];
b[3] = tmp;
}
return v;
}
void Ship::CutsceneV0::ParseFileBinary(BinaryReader* reader, Resource* res)
{
@@ -9,11 +108,413 @@ void Ship::CutsceneV0::ParseFileBinary(BinaryReader* reader, Resource* res)
uint32_t numEntries = reader->ReadUInt32();
cs->commands.reserve(numEntries);
for (uint32_t i = 0; i < numEntries; i++)
{
uint32_t data = reader->ReadUInt32();
uint16_t opcode = data >> 16;
uint32_t numCommands = reader->ReadUInt32();
cs->commands.push_back(numCommands);
cs->commands.push_back(data);
// endFrame
cs->commands.push_back(reader->ReadUInt32());
while (true)
{
uint32_t commandId = reader->ReadUInt32();
cs->commands.push_back(commandId);
switch (commandId)
{
case (uint32_t)CutsceneCommands::SetCameraPos:
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
while (true)
{
uint32_t val = read_CMD_BBH(reader);
int8_t continueFlag = ((int8_t*)&val)[0];
cs->commands.push_back(val);
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
if (continueFlag == -1)
break;
}
}
break;
case (uint32_t)CutsceneCommands::SetCameraFocus:
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
while (true)
{
uint32_t val = read_CMD_BBH(reader);
int8_t continueFlag = ((int8_t*)&val)[0];
cs->commands.push_back(val);
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
if (continueFlag == -1)
break;
}
break;
}
case (uint32_t)CutsceneCommands::SpecialAction:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
}
break;
}
case (uint32_t)CutsceneCommands::SetLighting:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
}
break;
}
case (uint32_t)CutsceneCommands::SetCameraPosLink:
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
while (true)
{
uint32_t val = read_CMD_BBH(reader);
int8_t continueFlag = ((int8_t*)&val)[0];
cs->commands.push_back(val);
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
if (continueFlag == -1)
break;
}
break;
}
case (uint32_t)CutsceneCommands::SetCameraFocusLink:
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
while (true)
{
uint32_t val = read_CMD_BBH(reader);
int8_t continueFlag = ((int8_t*)&val)[0];
cs->commands.push_back(val);
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
if (continueFlag == -1)
break;
}
break;
}
case (uint32_t)CutsceneCommands::Cmd09:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HBB(reader));
cs->commands.push_back(read_CMD_BBH(reader));
}
break;
}
case 0x15:
case (uint32_t)CutsceneCommands::Unknown:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
}
}
break;
case (uint32_t)CutsceneCommands::Textbox:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
}
break;
}
case (uint32_t)CutsceneCommands::SetActorAction0:
case (uint32_t)CutsceneCommands::SetActorAction1:
case 17:
case 18:
case 23:
case 34:
case 39:
case 46:
case 76:
case 85:
case 93:
case 105:
case 107:
case 110:
case 119:
case 123:
case 138:
case 139:
case 144:
case (uint32_t)CutsceneCommands::SetActorAction2:
case 16:
case 24:
case 35:
case 40:
case 48:
case 64:
case 68:
case 70:
case 78:
case 80:
case 94:
case 116:
case 118:
case 120:
case 125:
case 131:
case 141:
case (uint32_t)CutsceneCommands::SetActorAction3:
case 36:
case 41:
case 50:
case 67:
case 69:
case 72:
case 74:
case 81:
case 106:
case 117:
case 121:
case 126:
case 132:
case (uint32_t)CutsceneCommands::SetActorAction4:
case 37:
case 42:
case 51:
case 53:
case 63:
case 65:
case 66:
case 75:
case 82:
case 108:
case 127:
case 133:
case (uint32_t)CutsceneCommands::SetActorAction5:
case 38:
case 43:
case 47:
case 54:
case 79:
case 83:
case 128:
case 135:
case (uint32_t)CutsceneCommands::SetActorAction6:
case 55:
case 77:
case 84:
case 90:
case 129:
case 136:
case (uint32_t)CutsceneCommands::SetActorAction7:
case 52:
case 57:
case 58:
case 88:
case 115:
case 130:
case 137:
case (uint32_t)CutsceneCommands::SetActorAction8:
case 60:
case 89:
case 111:
case 114:
case 134:
case 142:
case (uint32_t)CutsceneCommands::SetActorAction9:
case (uint32_t)CutsceneCommands::SetActorAction10:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
}
break;
}
case (uint32_t)CutsceneCommands::SetSceneTransFX:
{
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
break;
}
case (uint32_t)CutsceneCommands::PlayBGM:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
}
break;
}
case (uint32_t)CutsceneCommands::StopBGM:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
}
break;
}
case (uint32_t)CutsceneCommands::FadeBGM:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(reader->ReadUInt32());
}
break;
}
case (uint32_t)CutsceneCommands::SetTime:
{
uint32_t size = reader->ReadUInt32();
cs->commands.push_back(size);
for (uint32_t i = 0; i < size; i++)
{
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HBB(reader));
cs->commands.push_back(reader->ReadUInt32());
}
break;
}
case (uint32_t)CutsceneCommands::Terminator:
{
cs->commands.push_back(reader->ReadUInt32());
cs->commands.push_back(read_CMD_HH(reader));
cs->commands.push_back(read_CMD_HH(reader));
break;
}
case 0xFFFFFFFF: // CS_END
{
cs->commands.push_back(reader->ReadUInt32());
return;
}
default:
SPDLOG_TRACE("CutsceneV0: Unknown command {}\n", commandId);
// error?
break;
}
}
}
+187 -15
View File
@@ -1,24 +1,24 @@
#include "Cvar.h"
#include <map>
#include <string>
#include <string.h>
#include <functional>
#include <memory>
#include <utility>
#include <PR/ultra64/gbi.h>
#include "imgui_internal.h"
#include <Utils/File.h>
#include "Window.h"
std::map<std::string, std::unique_ptr<CVar>, std::less<>> cvars;
extern "C" CVar* CVar_Get(const char* name) {
CVar* CVar_Get(const char* name) {
auto it = cvars.find(name);
return (it != cvars.end()) ? it->second.get() : nullptr;
}
extern "C" s32 CVar_GetS32(const char* name, s32 defaultValue) {
extern "C" int32_t CVar_GetS32(const char* name, int32_t defaultValue) {
CVar* cvar = CVar_Get(name);
if (cvar) {
if (cvar->type == CVAR_TYPE_S32)
if (cvar->type == CVarType::S32)
return cvar->value.valueS32;
}
@@ -29,7 +29,7 @@ extern "C" float CVar_GetFloat(const char* name, float defaultValue) {
CVar* cvar = CVar_Get(name);
if (cvar) {
if (cvar->type == CVAR_TYPE_FLOAT)
if (cvar->type == CVarType::Float)
return cvar->value.valueFloat;
}
@@ -40,28 +40,68 @@ extern "C" const char* CVar_GetString(const char* name, const char* defaultValue
CVar* cvar = CVar_Get(name);
if (cvar) {
if (cvar->type == CVAR_TYPE_STRING)
if (cvar->type == CVarType::String)
return cvar->value.valueStr;
}
return defaultValue;
}
extern "C" void CVar_SetS32(const char* name, s32 value) {
extern "C" Color_RGB8 CVar_GetRGB(const char* name, Color_RGB8 defaultValue)
{
Color_RGBA8 defaultValueRGBA;
defaultValueRGBA.r = defaultValue.r;
defaultValueRGBA.g = defaultValue.g;
defaultValueRGBA.b = defaultValue.b;
defaultValueRGBA.a = 255;
Color_RGBA8 cvarGet = CVar_GetRGBA(name, defaultValueRGBA);
Color_RGB8 result;
result.r = cvarGet.r;
result.g = cvarGet.g;
result.b = cvarGet.b;
return result;
}
extern "C" Color_RGBA8 CVar_GetRGBA(const char* name, Color_RGBA8 defaultValue) {
CVar* cvar = CVar_Get(name);
if (cvar != nullptr) {
if (cvar->type == CVarType::RGBA)
return cvar->value.valueRGBA;
}
return defaultValue;
}
extern "C" void CVar_SetRGBA(const char* name, Color_RGBA8 value)
{
auto& cvar = cvars[name];
if (!cvar) {
cvar = std::make_unique<CVar>();
}
cvar->type = CVAR_TYPE_S32;
cvar->type = CVarType::RGBA;
cvar->value.valueRGBA = value;
}
extern "C" void CVar_SetS32(const char* name, int32_t value) {
auto& cvar = cvars[name];
if (!cvar) {
cvar = std::make_unique<CVar>();
}
cvar->type = CVarType::S32;
cvar->value.valueS32 = value;
}
void CVar_SetFloat(const char* name, float value) {
extern "C" void CVar_SetFloat(const char* name, float value) {
auto& cvar = cvars[name];
if (!cvar) {
cvar = std::make_unique<CVar>();
}
cvar->type = CVAR_TYPE_FLOAT;
cvar->type = CVarType::Float;
cvar->value.valueFloat = value;
}
@@ -70,11 +110,20 @@ extern "C" void CVar_SetString(const char* name, const char* value) {
if (!cvar) {
cvar = std::make_unique<CVar>();
}
cvar->type = CVAR_TYPE_STRING;
cvar->value.valueStr = ImStrdup(value);
cvar->type = CVarType::String;
#ifdef _MSC_VER
cvar->value.valueStr = _strdup(value);
#else
cvar->value.valueStr = strdup(value);
#endif
}
extern "C" void CVar_RegisterS32(const char* name, s32 defaultValue) {
extern "C" void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue) {
if (!CVar_Get(name))
CVar_SetRGBA(name, defaultValue);
}
extern "C" void CVar_RegisterS32(const char* name, int32_t defaultValue) {
if (!CVar_Get(name))
CVar_SetS32(name, defaultValue);
}
@@ -88,3 +137,126 @@ extern "C" void CVar_RegisterString(const char* name, const char* defaultValue)
if (!CVar_Get(name))
CVar_SetString(name, defaultValue);
}
template <typename Numeric> bool is_number(const std::string& s) {
Numeric n;
return ((std::istringstream(s) >> n >> std::ws).eof());
}
void CVar_LoadLegacy() {
auto cvarsConfig = Ship::Window::GetPathRelativeToAppDirectory("cvars.cfg");
if (File::Exists(cvarsConfig)) {
const auto lines = File::ReadAllLines(cvarsConfig);
for (const std::string& line : lines) {
std::vector<std::string> cfg = StringHelper::Split(line, " = ");
if (line.empty()) continue;
if (cfg.size() < 2) continue;
if (cfg[1].find("\"") == std::string::npos && (cfg[1].find("#") != std::string::npos))
{
std::string value(cfg[1]);
value.erase(std::remove_if(value.begin(), value.end(), [](char c) { return c == '#'; }), value.end());
auto splitTest = StringHelper::Split(value, "\r")[0];
uint32_t val = std::stoul(splitTest, nullptr, 16);
Color_RGBA8 clr;
clr.r = val >> 24;
clr.g = val >> 16;
clr.b = val >> 8;
clr.a = val & 0xFF;
CVar_SetRGBA(cfg[0].c_str(), clr);
}
if (cfg[1].find("\"") != std::string::npos) {
std::string value(cfg[1]);
value.erase(std::remove(value.begin(), value.end(), '\"'), value.end());
#ifdef _MSC_VER
CVar_SetString(cfg[0].c_str(), _strdup(value.c_str()));
#else
CVar_SetString(cfg[0].c_str(), strdup(value.c_str()));
#endif
}
if (is_number<float>(cfg[1])) {
CVar_SetFloat(cfg[0].c_str(), std::stof(cfg[1]));
}
if (is_number<int>(cfg[1])) {
CVar_SetS32(cfg[0].c_str(), std::stoi(cfg[1]));
}
}
fs::remove(cvarsConfig);
}
}
extern "C" void CVar_Load() {
std::shared_ptr<Mercury> pConf = Ship::Window::GetInstance()->GetConfig();
pConf->reload();
for (const auto& item : pConf->rjson["CVars"].items()) {
auto value = item.value();
switch (value.type()) {
case nlohmann::detail::value_t::array:
break;
case nlohmann::detail::value_t::object:
if (value["Type"].get<std::string>() == mercuryRGBAObjectType) {
Color_RGBA8 clr;
clr.r = value["R"].get<uint8_t>();
clr.g = value["G"].get<uint8_t>();
clr.b = value["B"].get<uint8_t>();
clr.a = value["A"].get<uint8_t>();
CVar_SetRGBA(item.key().c_str(), clr);
}
break;
case nlohmann::detail::value_t::string:
CVar_SetString(item.key().c_str(), value.get<std::string>().c_str());
break;
case nlohmann::detail::value_t::boolean:
CVar_SetS32(item.key().c_str(), value.get<bool>());
break;
case nlohmann::detail::value_t::number_unsigned:
case nlohmann::detail::value_t::number_integer:
CVar_SetS32(item.key().c_str(), value.get<int>());
break;
case nlohmann::detail::value_t::number_float:
CVar_SetFloat(item.key().c_str(), value.get<float>());
break;
default:;
}
if (item.key() == "gOpenMenuBar") {
int bp = 0;
}
}
CVar_LoadLegacy();
}
extern "C" void CVar_Save()
{
std::shared_ptr<Mercury> pConf = Ship::Window::GetInstance()->GetConfig();
for (const auto& cvar : cvars) {
const std::string key = StringHelper::Sprintf("CVars.%s", cvar.first.c_str());
if (cvar.second->type == CVarType::String && cvar.second->value.valueStr != nullptr)
pConf->setString(key, std::string(cvar.second->value.valueStr));
else if (cvar.second->type == CVarType::S32)
pConf->setInt(key, cvar.second->value.valueS32);
else if (cvar.second->type == CVarType::Float)
pConf->setFloat(key, cvar.second->value.valueFloat);
else if (cvar.second->type == CVarType::RGBA)
{
auto keyStr = key.c_str();
Color_RGBA8 clr = cvar.second->value.valueRGBA;
pConf->setUInt(StringHelper::Sprintf("%s.R", keyStr), clr.r);
pConf->setUInt(StringHelper::Sprintf("%s.G", keyStr), clr.g);
pConf->setUInt(StringHelper::Sprintf("%s.B", keyStr), clr.b);
pConf->setUInt(StringHelper::Sprintf("%s.A", keyStr), clr.a);
pConf->setString(StringHelper::Sprintf("%s.Type", keyStr), mercuryRGBAObjectType);
}
}
pConf->save();
}
+31 -15
View File
@@ -1,37 +1,55 @@
#ifndef _CVAR_H
#define _CVAR_H
#include <PR/ultra64/gbi.h>
#include "color.h"
#include <stdint.h>
typedef enum CVarType { CVAR_TYPE_S32, CVAR_TYPE_FLOAT, CVAR_TYPE_STRING } CVarType;
#ifdef __cplusplus
typedef enum class CVarType
{
S32,
Float,
String,
RGBA
} CVarType;
typedef struct CVar {
const char* name;
CVarType type;
union {
s32 valueS32;
int32_t valueS32;
float valueFloat;
const char* valueStr;
Color_RGBA8 valueRGBA;
} value;
} CVar;
extern "C" CVar * CVar_Get(const char* name);
#endif
#ifdef __cplusplus
extern "C"
{
#endif
//#include <ultra64.h>
CVar* CVar_Get(const char* name);
s32 CVar_GetS32(const char* name, s32 defaultValue);
float CVar_GetFloat(const char* name, float defaultValue);
const char* CVar_GetString(const char* name, const char* defaultValue);
void CVar_SetS32(const char* name, s32 value);
void CVar_SetString(const char* name, const char* value);
float CVar_GetFloat(const char* name, float defaultValue);
void CVar_SetFloat(const char* name, float value);
int32_t CVar_GetS32(const char* name, int32_t defaultValue);
void CVar_SetS32(const char* name, int32_t value);
const char* CVar_GetString(const char* name, const char* defaultValue);
void CVar_SetString(const char* name, const char* value);
Color_RGB8 CVar_GetRGB(const char* name, Color_RGB8 defaultValue);
Color_RGBA8 CVar_GetRGBA(const char* name, Color_RGBA8 defaultValue);
void CVar_SetRGBA(const char* name, Color_RGBA8 value);
void CVar_RegisterS32(const char* name, s32 defaultValue);
void CVar_RegisterFloat(const char* name, float defaultValue);
void CVar_RegisterString(const char* name, const char* defaultValue);
void CVar_RegisterS32(const char* name, int32_t defaultValue);
void CVar_RegisterFloat(const char* name, float defaultValue);
void CVar_RegisterString(const char* name, const char* defaultValue);
void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue);
void CVar_Load();
void CVar_Save();
#ifdef __cplusplus
};
@@ -40,10 +58,8 @@ void CVar_RegisterString(const char* name, const char* defaultValue);
#ifdef __cplusplus
#include <map>
#include <string>
#include <functional>
#include <memory>
extern std::map<std::string, std::unique_ptr<CVar>, std::less<>> cvars;
void CVar_SetFloat(const char* name, float value);
#endif
#endif
@@ -1,31 +0,0 @@
#pragma once
#include <vector>
#include <optional>
#include "Controller.h"
class DisconnectedController final : public Ship::Controller {
public:
DisconnectedController() {
GUID = "Disconnected";
}
std::map<std::vector<std::string>, int32_t> ReadButtonPress();
void ReadFromSource(int32_t slot) override {}
const char* GetControllerName() override { return "Disconnected"; }
const char* GetButtonName(int slot, int n64Button) override { return "None"; }
void WriteToSource(int32_t slot, ControllerCallback* controller) override { }
bool Connected() const override { return false; }
bool CanRumble() const override { return false; }
bool CanGyro() const override { return false; }
void ClearRawPress() override {}
int32_t ReadRawPress() override { return -1; }
bool HasPadConf() const { return true; }
std::optional<std::string> GetPadConfSection() { return "Unk"; }
void CreateDefaultBinding(int32_t slot) override {}
protected:
std::string GetControllerType() { return "Unk"; }
std::string GetConfSection() { return "Unk"; }
std::string GetBindingConfSection() { return "Unk"; }
};
+12 -12
View File
@@ -14,23 +14,25 @@ namespace Ship
while (true)
{
uint64_t data = reader->ReadUInt64();
uint32_t w0 = reader->ReadUInt32();
uint32_t w1 = reader->ReadUInt32();
if (sizeof(uintptr_t) < 8){
dl->instructions.push_back(data);
dl->instructions.push_back(((uint64_t) w0 << 32) | w1);
uint8_t opcode = data >> 24;
uint8_t opcode = w0 >> 24;
// These are 128-bit commands, so read an extra 64 bits...
if (opcode == G_SETTIMG_OTR || opcode == G_DL_OTR || opcode == G_VTX_OTR || opcode == G_BRANCH_Z_OTR || opcode == G_MARKER || opcode == G_MTX_OTR)
dl->instructions.push_back(reader->ReadUInt64());
if (opcode == G_SETTIMG_OTR || opcode == G_DL_OTR || opcode == G_VTX_OTR || opcode == G_BRANCH_Z_OTR || opcode == G_MARKER || opcode == G_MTX_OTR) {
w0 = reader->ReadUInt32();
w1 = reader->ReadUInt32();
dl->instructions.push_back(((uint64_t) w0 << 32) | w1);
}
if (opcode == G_ENDDL)
break;
} else {
uint32_t w0 = (uint32_t)data;
uint32_t w1 = (uint32_t)(data >> 32);
dl->instructions.push_back(w0);
dl->instructions.push_back(w1);
@@ -38,10 +40,8 @@ namespace Ship
if (opcode == G_SETTIMG_OTR || opcode == G_DL_OTR || opcode == G_VTX_OTR || opcode == G_BRANCH_Z_OTR || opcode == G_MARKER || opcode == G_MTX_OTR)
{
data = reader->ReadUInt64();
w0 = (uint32_t)data;
w1 = (uint32_t)(data >> 32);
w0 = reader->ReadUInt32();
w1 = reader->ReadUInt32();
dl->instructions.push_back(w0);
dl->instructions.push_back(w1);
@@ -0,0 +1,61 @@
#include "DummyController.h"
namespace Ship {
DummyController::DummyController(const std::string& CUID, const std::string& KeyName, bool Connected) {
GUID = CUID;
isConnected = Connected;
ButtonName = KeyName;
}
void DummyController::ReadFromSource(int32_t virtualSlot) {
}
const std::string DummyController::GetControllerName() {
return GUID;
}
const std::string DummyController::GetButtonName(int32_t virtualSlot, int32_t n64Button) {
return ButtonName;
}
void DummyController::WriteToSource(int32_t virtualSlot, ControllerCallback* controller){
}
bool DummyController::Connected() const {
return isConnected;
}
bool DummyController::CanRumble() const {
return false;
}
bool DummyController::CanGyro() const {
return false;
}
void DummyController::CreateDefaultBinding(int32_t slot) {
}
std::string DummyController::GetControllerType() {
return "Unk";
}
std::string DummyController::GetConfSection() {
return "Unk";
}
std::string DummyController::GetBindingConfSection() {
return "Unk";
}
void DummyController::ClearRawPress() {
}
int32_t DummyController::ReadRawPress() {
return -1;
}
}
@@ -0,0 +1,31 @@
#pragma once
#include <vector>
#include <optional>
#include "Controller.h"
namespace Ship {
class DummyController final : public Controller {
public:
DummyController(const std::string& CUID, const std::string& KeyName, bool Connected);
std::map<std::vector<std::string>, int32_t> ReadButtonPress();
void ReadFromSource(int32_t virtualSlot) override;
const std::string GetControllerName() override;
const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) override;
void WriteToSource(int32_t slot, ControllerCallback* controller) override;
bool Connected() const override;
bool CanRumble() const override;
bool CanGyro() const override;
void ClearRawPress() override;
int32_t ReadRawPress() override;
bool HasPadConf() const;
std::optional<std::string> GetPadConfSection();
void CreateDefaultBinding(int32_t virtualSlot) override;
protected:
std::string ButtonName;
bool isConnected = false;
std::string GetControllerType();
std::string GetConfSection();
std::string GetBindingConfSection();
};
}
-15
View File
@@ -1,15 +0,0 @@
#include "Environment.h"
#include <map>
#include <string>
std::map<std::string, std::string> environmentVars;
namespace SohUtils {
void saveEnvironmentVar(const std::string& key, const std::string& value) {
environmentVars[key] = value;
}
std::string getEnvironmentVar(const std::string& key) {
return environmentVars[key];
}
}
-8
View File
@@ -1,8 +0,0 @@
#pragma once
#include <string>
namespace SohUtils {
void saveEnvironmentVar(const std::string& key, const std::string& value);
std::string getEnvironmentVar(const std::string& key);
}
@@ -25,12 +25,12 @@ namespace Ship
auto memStream = std::make_shared<MemoryStream>(FileToLoad->buffer.get(), FileToLoad->dwBufferSize);
auto reader = std::make_shared<BinaryReader>(memStream);
Endianess endianess = (Endianess)reader->ReadByte();
Endianness endianness = (Endianness)reader->ReadByte();
for (int i = 0; i < 3; i++)
reader->ReadByte();
// OTRTODO: Setup the binaryreader to use the resource's endianess
reader->SetEndianness(endianness);
ResourceType resourceType = (ResourceType)reader->ReadUInt32();
Resource* result = nullptr;
+2 -1
View File
@@ -2,7 +2,8 @@
#include <string>
#include <memory>
#include "GlobalCtx2.h"
#include <mutex>
#include <condition_variable>
namespace Ship {
class Archive;
+216 -202
View File
@@ -4,222 +4,236 @@
#include "File.h"
#include "Archive.h"
#include "ResourceMgr.h"
#include "Console.h"
#include "ImGuiImpl.h"
#include "TextureMod.h"
#include "Lib/ImGui/imgui_internal.h"
#include "Utils/StringHelper.h"
void Ship::GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) {
ImGuiIO& io = ImGui::GetIO();
std::shared_ptr<Archive> base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive();
std::shared_ptr<File> font = std::make_shared<File>();
base->LoadFile(path, false, font);
if (font->bIsLoaded) {
char* font_data = new char[font->dwBufferSize];
memcpy(font_data, font->buffer.get(), font->dwBufferSize);
Fonts[name] = io.Fonts->AddFontFromMemoryTTF(font_data, font->dwBufferSize, fontSize);
namespace Ship {
bool GameOverlay::OverlayCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args) {
if (args.size() < 3) {
return CMD_FAILED;
}
if (CVar_Get(args[2].c_str()) != nullptr) {
const char* key = args[2].c_str();
GameOverlay* overlay = SohImGui::GetGameOverlay();
if (args[1] == "add") {
if (!overlay->RegisteredOverlays.contains(key)) {
overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f });
SohImGui::GetConsole()->SendInfoMessage("Added overlay: %s", key);
}
else {
SohImGui::GetConsole()->SendErrorMessage("Overlay already exists: %s", key);
}
}
else if (args[1] == "remove") {
if (overlay->RegisteredOverlays.contains(key)) {
overlay->RegisteredOverlays.erase(key);
SohImGui::GetConsole()->SendInfoMessage("Removed overlay: %s", key);
}
else {
SohImGui::GetConsole()->SendErrorMessage("Overlay not found: %s", key);
}
}
}
else {
SohImGui::GetConsole()->SendErrorMessage("CVar {} does not exist", args[2].c_str());
}
return CMD_SUCCESS;
}
}
void Ship::GameOverlay::TextDraw(float x, float y, bool shadow, ImVec4 color, const char* fmt, ...) {
char buf[1024];
va_list args;
va_start(args, fmt);
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf) - 1] = 0;
va_end(args);
void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) {
ImGuiIO& io = ImGui::GetIO();
std::shared_ptr<Archive> base = Window::GetInstance()->GetResourceManager()->GetArchive();
std::shared_ptr<File> font = std::make_shared<File>();
base->LoadFile(path, false, font);
if (font->bIsLoaded) {
char* font_data = new char[font->dwBufferSize];
memcpy(font_data, font->buffer.get(), font->dwBufferSize);
Fonts[name] = io.Fonts->AddFontFromMemoryTTF(font_data, font->dwBufferSize, fontSize);
}
}
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::PushFont(Fonts[this->CurrentFont]);
if (shadow) {
ImGui::SetCursorPos(ImVec2(x + 1, y + 1));
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(.0f, .0f, .0f, color.w));
void GameOverlay::TextDraw(float x, float y, bool shadow, ImVec4 color, const char* fmt, ...) {
char buf[1024];
va_list args;
va_start(args, fmt);
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf) - 1] = 0;
va_end(args);
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::PushFont(Fonts[this->CurrentFont]);
if (shadow) {
ImGui::SetCursorPos(ImVec2(x + 1, y + 1));
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(.0f, .0f, .0f, color.w));
ImGui::Text(buf, args);
}
ImGui::PopStyleColor();
ImGui::SetCursorPos(ImVec2(x, y));
ImGui::Text(buf, args);
ImGui::PopFont();
ImGui::PopStyleColor();
}
ImGui::PopStyleColor();
ImGui::SetCursorPos(ImVec2(x, y));
ImGui::Text(buf, args);
ImGui::PopFont();
ImGui::PopStyleColor();
}
void Ship::GameOverlay::TextDrawNotification(float duration, bool shadow, const char* fmt, ...) {
char buf[1024];
va_list args;
va_start(args, fmt);
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf) - 1] = 0;
va_end(args);
this->RegisteredOverlays[StringHelper::Sprintf("NotificationID:%d%d", rand(), this->RegisteredOverlays.size())] = new Overlay({ OverlayType::NOTIFICATION, ImStrdup(buf), duration, duration });
NeedsCleanup = true;
}
void Ship::GameOverlay::CleanupNotifications() {
if(!NeedsCleanup) return;
for (auto it = this->RegisteredOverlays.begin(); it != this->RegisteredOverlays.end(); ) {
if (it->second->type == OverlayType::NOTIFICATION && it->second->duration <= 0.0f) {
it = this->RegisteredOverlays.erase(it);
} else {
++it;
}
void GameOverlay::TextDrawNotification(float duration, bool shadow, const char* fmt, ...) {
char buf[1024];
va_list args;
va_start(args, fmt);
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
buf[IM_ARRAYSIZE(buf) - 1] = 0;
va_end(args);
this->RegisteredOverlays[StringHelper::Sprintf("NotificationID:%d%d", rand(), this->RegisteredOverlays.size())] = new Overlay({ OverlayType::NOTIFICATION, ImStrdup(buf), duration, duration });
NeedsCleanup = true;
}
NeedsCleanup = false;
}
float Ship::GameOverlay::GetScreenWidth() {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
return viewport->Size.x;
}
float Ship::GameOverlay::GetScreenHeight() {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
return viewport->Size.y;
}
float Ship::GameOverlay::GetStringWidth(const char* text) {
return CalculateTextSize(text).x;
}
ImVec2 Ship::GameOverlay::CalculateTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) {
ImGuiContext& g = *GImGui;
const char* text_display_end;
if (hide_text_after_double_hash)
text_display_end = ImGui::FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
else
text_display_end = text_end;
GameOverlay* overlay = SohImGui::overlay;
ImFont* font = overlay->CurrentFont == "Default" ? g.Font : overlay->Fonts[overlay->CurrentFont];
const float font_size = font->FontSize;
if (text == text_display_end)
return ImVec2(0.0f, font_size);
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
// Round
// FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out.
// FIXME: Investigate using ceilf or e.g.
// - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c
// - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html
text_size.x = IM_FLOOR(text_size.x + 0.99999f);
return text_size;
}
void Ship::GameOverlay::Init() {
this->LoadFont("Press Start 2P", "assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf", 12.0f);
this->LoadFont("Fipps", "assets/ship_of_harkinian/fonts/Fipps-Regular.otf", 32.0f);
const std::string DefaultFont = this->Fonts.begin()->first;
if(!this->Fonts.empty()) {
const std::string font = CVar_GetString("gOverlayFont", ImStrdup(DefaultFont.c_str()));
for (auto& [name, _] : this->Fonts) {
if (font.starts_with(name)) {
this->CurrentFont = name;
break;
void GameOverlay::CleanupNotifications() {
if (!NeedsCleanup) return;
for (auto it = this->RegisteredOverlays.begin(); it != this->RegisteredOverlays.end(); ) {
if (it->second->type == OverlayType::NOTIFICATION && it->second->duration <= 0.0f) {
it = this->RegisteredOverlays.erase(it);
}
this->CurrentFont = DefaultFont;
}
}
SohImGui::console->Commands["overlay"] = { OverlayCommand, "Draw an overlay using a cvar value" };
}
void Ship::GameOverlay::DrawSettings() {
ImGui::Text("Overlays Text Font");
if (ImGui::BeginCombo("##TextFont", this->CurrentFont.c_str())) {
for (auto& [name, font] : this->Fonts) {
if (ImGui::Selectable(name.c_str(), name == this->CurrentFont)) {
this->CurrentFont = name;
CVar_SetString("gOverlayFont", ImStrdup(name.c_str()));
SohImGui::needs_save = true;
}
}
ImGui::EndCombo();
}
}
void Ship::GameOverlay::Draw() {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos, ImGuiCond_Always);
ImGui::SetNextWindowSize(viewport->Size, ImGuiCond_Always);
ImGui::Begin("SoHOverlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground |
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs);
this->CleanupNotifications();
float textY = 50;
float notY = 0;
for (auto &[key, overlay] : this->RegisteredOverlays) {
if (overlay->type == OverlayType::TEXT) {
const char* text = ImStrdup(overlay->value);
const CVar* var = CVar_Get(text);
ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
switch (var->type) {
case CVAR_TYPE_FLOAT:
this->TextDraw(30, textY, true, color, "%s %.2f", text, var->value.valueFloat);
break;
case CVAR_TYPE_S32:
this->TextDraw(30, textY, true, color, "%s %d", text, var->value.valueS32);
break;
case CVAR_TYPE_STRING:
this->TextDraw(30, textY, true, color, "%s %s", text, var->value.valueStr);
break;
}
free((void*) text);
textY += 30;
}
if (overlay->type == OverlayType::NOTIFICATION && overlay->duration > 0) {
const char* text = overlay->value;
const float duration = overlay->duration / overlay->fadeTime;
const ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, duration);
const float textWidth = this->GetStringWidth(overlay->value);
this->TextDraw(GetScreenWidth() - textWidth - 40, GetScreenHeight() - 40 - notY, true, color, text);
notY += 30;
overlay->duration -= .05f;
}
}
ImGui::End();
}
bool Ship::OverlayCommand(const std::vector<std::string>& args) {
if (args.size() < 3) {
return CMD_FAILED;
}
if (CVar_Get(args[2].c_str()) != nullptr) {
const char* key = args[2].c_str();
GameOverlay* overlay = SohImGui::overlay;
if (args[1] == "add") {
if (!overlay->RegisteredOverlays.contains(key)) {
overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f });
INFO("Added overlay: %s ", key);
} else {
ERROR("Overlay already exists: %s", key);
}
} else if (args[1] == "remove") {
if (overlay->RegisteredOverlays.contains(key)) {
overlay->RegisteredOverlays.erase(key);
INFO("Removed overlay: %s ", key);
} else {
ERROR("Overlay not found: %s ", key);
else {
++it;
}
}
} else {
ERROR("CVar %s does not exist", args[2].c_str());
NeedsCleanup = false;
}
return CMD_SUCCESS;
}
float GameOverlay::GetScreenWidth() {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
return viewport->Size.x;
}
float GameOverlay::GetScreenHeight() {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
return viewport->Size.y;
}
float GameOverlay::GetStringWidth(const char* text) {
return CalculateTextSize(text).x;
}
ImVec2 GameOverlay::CalculateTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) {
ImGuiContext& g = *GImGui;
const char* text_display_end;
if (hide_text_after_double_hash)
text_display_end = ImGui::FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
else
text_display_end = text_end;
GameOverlay* overlay = SohImGui::GetGameOverlay();
ImFont* font = overlay->CurrentFont == "Default" ? g.Font : overlay->Fonts[overlay->CurrentFont];
const float font_size = font->FontSize;
if (text == text_display_end)
return ImVec2(0.0f, font_size);
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
// Round
// FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out.
// FIXME: Investigate using ceilf or e.g.
// - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c
// - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html
text_size.x = IM_FLOOR(text_size.x + 0.99999f);
return text_size;
}
void GameOverlay::Init() {
this->LoadFont("Press Start 2P", "assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf", 12.0f);
this->LoadFont("Fipps", "assets/ship_of_harkinian/fonts/Fipps-Regular.otf", 32.0f);
const std::string DefaultFont = this->Fonts.begin()->first;
if (!this->Fonts.empty()) {
const std::string font = CVar_GetString("gOverlayFont", ImStrdup(DefaultFont.c_str()));
for (auto& [name, _] : this->Fonts) {
if (font.starts_with(name)) {
this->CurrentFont = name;
break;
}
this->CurrentFont = DefaultFont;
}
}
SohImGui::GetConsole()->AddCommand("overlay", { OverlayCommand, "Draw an overlay using a cvar value" });
}
void GameOverlay::DrawSettings() {
ImGui::Text("Overlays Text Font");
if (ImGui::BeginCombo("##TextFont", this->CurrentFont.c_str())) {
for (auto& [name, font] : this->Fonts) {
if (ImGui::Selectable(name.c_str(), name == this->CurrentFont)) {
this->CurrentFont = name;
CVar_SetString("gOverlayFont", ImStrdup(name.c_str()));
SohImGui::RequestCvarSaveOnNextTick();
}
}
ImGui::EndCombo();
}
}
void GameOverlay::Draw() {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos, ImGuiCond_Always);
ImGui::SetNextWindowSize(viewport->Size, ImGuiCond_Always);
ImGui::Begin("SoHOverlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground |
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs);
this->CleanupNotifications();
float textY = 50;
float notY = 0;
for (auto& [key, overlay] : this->RegisteredOverlays) {
if (overlay->type == OverlayType::TEXT) {
const char* text = ImStrdup(overlay->value);
const CVar* var = CVar_Get(text);
ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
switch (var->type) {
case CVarType::Float:
this->TextDraw(30, textY, true, color, "%s %.2f", text, var->value.valueFloat);
break;
case CVarType::S32:
this->TextDraw(30, textY, true, color, "%s %d", text, var->value.valueS32);
break;
case CVarType::String:
this->TextDraw(30, textY, true, color, "%s %s", text, var->value.valueStr);
break;
case CVarType::RGBA:
this->TextDraw(30, textY, true, color, "#%08X", text, var->value.valueRGBA);
break;
}
free((void*)text);
textY += 30;
}
if (overlay->type == OverlayType::NOTIFICATION && overlay->duration > 0) {
const char* text = overlay->value;
const float duration = overlay->duration / overlay->fadeTime;
const ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, duration);
#ifdef __WIIU__
const float textWidth = this->GetStringWidth(overlay->value) * 2.0f;
const float textOffset = 40.0f * 2.0f;
#else
const float textWidth = this->GetStringWidth(overlay->value);
const float textOffset = 40.0f;
#endif
this->TextDraw(GetScreenWidth() - textWidth - textOffset, GetScreenHeight() - textOffset - notY, true, color, text);
notY += 30;
overlay->duration -= .05f;
}
}
ImGui::End();
}
}
+20 -17
View File
@@ -1,28 +1,29 @@
#pragma once
#include <string>
#include <vector>
#include <memory>
#include "Console.h"
#include "Lib/ImGui/imgui.h"
#include <map>
#include <unordered_map>
enum class OverlayType {
TEXT, IMAGE, NOTIFICATION
};
struct Overlay {
OverlayType type;
const char* value;
float fadeTime;
float duration;
};
namespace Ship {
enum class OverlayType {
TEXT, IMAGE, NOTIFICATION
};
struct Overlay {
OverlayType type;
const char* value;
float fadeTime;
float duration;
};
class GameOverlay {
public:
std::unordered_map<std::string, Overlay*> RegisteredOverlays;
std::unordered_map<std::string, ImFont*> Fonts;
std::string CurrentFont = "Default";
static bool OverlayCommand(std::shared_ptr<Console> Console, const std::vector<std::string>& args);
void Init();
void Draw();
void DrawSettings();
@@ -33,10 +34,12 @@ namespace Ship {
void TextDraw(float x, float y, bool shadow, ImVec4 color, const char* text, ...);
void TextDrawNotification(float duration, bool shadow, const char* fmt, ...);
private:
std::unordered_map<std::string, ImFont*> Fonts;
std::unordered_map<std::string, Overlay*> RegisteredOverlays;
std::string CurrentFont = "Default";
bool NeedsCleanup = false;
void CleanupNotifications();
void LoadFont(const std::string& name, const std::string& path, float fontSize);
};
static bool OverlayCommand(const std::vector<std::string>& args);
}
@@ -1,56 +0,0 @@
#include "GameSettings.h"
// Audio
#include <cstddef>
#include <PR/ultra64/types.h>
#include <PR/ultra64/sptask.h>
#include <PR/ultra64/pi.h>
#include <PR/ultra64/message.h>
#include "Cvar.h"
#include "GlobalCtx2.h"
#include "ImGuiImpl.h"
#include "../../soh/include/z64audio.h"
#include "Hooks.h"
#include "../../soh/soh/Enhancements/debugconsole.h"
#include "Window.h"
#include "Lib/Fast3D/gfx_rendering_api.h"
#define ABS(var) var < 0 ? -(var) : var
using namespace Ship;
namespace Game {
bool DeSyncAudio = false;
void UpdateAudio() {
Audio_SetGameVolume(SEQ_BGM_MAIN, CVar_GetFloat("gMainMusicVolume", 1));
Audio_SetGameVolume(SEQ_BGM_SUB, CVar_GetFloat("gSubMusicVolume", 1));
Audio_SetGameVolume(SEQ_FANFARE, CVar_GetFloat("gSFXMusicVolume", 1));
Audio_SetGameVolume(SEQ_SFX, CVar_GetFloat("gFanfareVolume", 1));
}
void LoadSettings() {
DebugConsole_LoadCVars();
}
void SaveSettings() {
DebugConsole_SaveCVars();
}
void InitSettings() {
ModInternal::RegisterHook<ModInternal::AudioInit>(UpdateAudio);
ModInternal::RegisterHook<ModInternal::GfxInit>([] {
gfx_get_current_rendering_api()->set_texture_filter((FilteringMode) CVar_GetS32("gTextureFilter", FILTER_THREE_POINT));
SohImGui::console->opened = CVar_GetS32("gConsoleEnabled", 0);
SohImGui::controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0);
UpdateAudio();
});
}
void SetSeqPlayerVolume(SeqPlayers playerId, float volume) {
Audio_SetGameVolume(playerId, volume);
}
}
-17
View File
@@ -1,17 +0,0 @@
#pragma once
enum SeqPlayers {
/* 0 */ SEQ_BGM_MAIN,
/* 1 */ SEQ_FANFARE,
/* 2 */ SEQ_SFX,
/* 3 */ SEQ_BGM_SUB,
/* 4 */ SEQ_MAX
};
namespace Game {
void InitSettings();
void LoadSettings();
void LoadPadSettings();
void SaveSettings();
void SetSeqPlayerVolume(SeqPlayers playerId, float volume);
}
-128
View File
@@ -1,128 +0,0 @@
#include "GlobalCtx2.h"
#include <iostream>
#include <vector>
#include "ResourceMgr.h"
#include "Window.h"
#include "spdlog/async.h"
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/sohconsole_sink.h"
#include "ModManager.h"
#ifdef __APPLE__
#include "OSXFolderManager.h"
#endif
namespace Ship {
std::weak_ptr<GlobalCtx2> GlobalCtx2::Context;
ModManager* INSTANCE;
std::shared_ptr<GlobalCtx2> GlobalCtx2::GetInstance() {
return Context.lock();
}
std::shared_ptr<GlobalCtx2> GlobalCtx2::CreateInstance(const std::string& Name) {
if (Context.expired()) {
auto Shared = std::make_shared<GlobalCtx2>(Name);
Context = Shared;
Shared->InitWindow();
return Shared;
} else {
SPDLOG_DEBUG("Trying to create a context when it already exists.");
}
return GetInstance();
}
std::string GlobalCtx2::GetAppDirectoryPath() {
#ifdef __APPLE__
FolderManager folderManager;
std::string fpath = std::string(folderManager.pathForDirectory(NSApplicationSupportDirectory, NSUserDomainMask));
fpath.append("/com.shipofharkinian.soh");
return fpath;
#endif
return ".";
}
std::string GlobalCtx2::GetPathRelativeToAppDirectory(const char* path) {
return GlobalCtx2::GetAppDirectoryPath() + "/" + path;
}
GlobalCtx2::GlobalCtx2(std::string Name) : Name(std::move(Name)) {
}
GlobalCtx2::~GlobalCtx2() {
SPDLOG_INFO("destruct GlobalCtx2");
INSTANCE->Exit();
}
void GlobalCtx2::InitWindow() {
InitLogging();
Config = std::make_shared<Mercury>(GetPathRelativeToAppDirectory("shipofharkinian.json"));
Config->reload();
MainPath = Config->getString("Game.Main Archive", GetPathRelativeToAppDirectory("oot.otr"));
PatchesPath = Config->getString("Game.Patches Archive", GetAppDirectoryPath() + "/mods");
ResMan = std::make_shared<ResourceMgr>(GetInstance(), MainPath, PatchesPath);
Win = std::make_shared<Window>(GetInstance());
if (!ResMan->DidLoadSuccessfully())
{
#ifdef _WIN32
MessageBox(nullptr, L"Main OTR file not found!", L"Uh oh", MB_OK);
#else
SPDLOG_ERROR("Main OTR file not found!");
#endif
exit(1);
}
INSTANCE = new ModManager(ResMan);
INSTANCE->Init();
}
void GlobalCtx2::InitLogging() {
try {
auto logPath = GetPathRelativeToAppDirectory(("logs/" + GetName() + ".log").c_str());
// Setup Logging
spdlog::init_thread_pool(8192, 1);
auto SohConsoleSink = std::make_shared<spdlog::sinks::soh_sink_mt>();
auto ConsoleSink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
auto FileSink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(logPath, 1024 * 1024 * 10, 10);
SohConsoleSink->set_level(spdlog::level::trace);
ConsoleSink->set_level(spdlog::level::trace);
FileSink->set_level(spdlog::level::trace);
std::vector<spdlog::sink_ptr> Sinks{ ConsoleSink, FileSink, SohConsoleSink };
Logger = std::make_shared<spdlog::async_logger>(GetName(), Sinks.begin(), Sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);
GetLogger()->set_level(spdlog::level::trace);
GetLogger()->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%@] [%l] %v");
spdlog::register_logger(GetLogger());
spdlog::set_default_logger(GetLogger());
}
catch (const spdlog::spdlog_ex& ex) {
std::cout << "Log initialization failed: " << ex.what() << std::endl;
}
}
void GlobalCtx2::WriteSaveFile(const std::filesystem::path& savePath, const uintptr_t addr, void* dramAddr, const size_t size) {
std::ofstream saveFile = std::ofstream(savePath, std::fstream::in | std::fstream::out | std::fstream::binary);
saveFile.seekp(addr);
saveFile.write((char*)dramAddr, size);
saveFile.close();
}
void GlobalCtx2::ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, void* dramAddr, size_t size) {
std::ifstream saveFile = std::ifstream(savePath, std::fstream::in | std::fstream::out | std::fstream::binary);
// If the file doesn't exist, initialize DRAM
if (saveFile.good()) {
saveFile.seekg(addr);
saveFile.read((char*)dramAddr, size);
} else {
memset(dramAddr, 0, size);
}
saveFile.close();
}
}
-54
View File
@@ -1,54 +0,0 @@
#ifndef GLOBAL_CTX_2
#define GLOBAL_CTX_2
#pragma once
#ifdef __cplusplus
#include <filesystem>
#include <memory>
#include <fstream>
#include "spdlog/spdlog.h"
#include "Lib/Mercury/Mercury.h"
namespace Ship {
class ResourceMgr;
class Window;
class GlobalCtx2 {
public:
static std::shared_ptr<GlobalCtx2> GetInstance();
static std::shared_ptr<GlobalCtx2> CreateInstance(const std::string& Name);
std::string GetName() { return Name; }
std::shared_ptr<Window> GetWindow() { return Win; }
std::shared_ptr<ResourceMgr> GetResourceManager() { return ResMan; }
std::shared_ptr<spdlog::logger> GetLogger() { return Logger; }
std::shared_ptr<Mercury> GetConfig() { return Config; }
static std::string GetAppDirectoryPath();
static std::string GetPathRelativeToAppDirectory(const char* path);
void WriteSaveFile(const std::filesystem::path& savePath, uintptr_t addr, void* dramAddr, size_t size);
void ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, void* dramAddr, size_t size);
GlobalCtx2(std::string Name);
~GlobalCtx2();
protected:
void InitWindow();
void InitLogging();
private:
static std::weak_ptr <GlobalCtx2> Context;
std::shared_ptr<spdlog::logger> Logger;
std::shared_ptr<Window> Win;
std::shared_ptr<Mercury> Config; // Config needs to be after the Window because we call the Window during it's destructor.
std::shared_ptr<ResourceMgr> ResMan;
std::string Name;
std::string MainPath;
std::string PatchesPath;
};
}
#endif
#endif
+2 -7
View File
@@ -1,10 +1,5 @@
#include "Hooks.h"
#include <map>
#include <string>
#include <vector>
#include <stdarg.h>
#include <iostream>
void ModInternal_ExecuteAudioInitHooks() {
ModInternal::ExecuteHooks<ModInternal::AudioInit>();
namespace Ship {
}
+5 -19
View File
@@ -1,15 +1,12 @@
#pragma once
#ifdef __cplusplus
#include <functional>
#include "UltraController.h"
#include "Controller.h"
#define DEFINE_HOOK(name, type) struct name { typedef std::function<type> fn; }
namespace ModInternal {
namespace Ship {
class Controller;
template <typename H>
struct RegisteredHooks {
@@ -29,22 +26,11 @@ namespace ModInternal {
}
DEFINE_HOOK(ControllerRead, void(OSContPad* cont_pad));
DEFINE_HOOK(ControllerRawInput, void(Ship::Controller* backend, uint32_t raw));
DEFINE_HOOK(ControllerRawInput, void(Controller* backend, uint32_t raw));
DEFINE_HOOK(AudioInit, void());
DEFINE_HOOK(LoadTexture, void(const char* path, uint8_t** texture));
DEFINE_HOOK(GfxInit, void());
DEFINE_HOOK(ExitGame, void());
DEFINE_HOOK(LoadFile, void(uint32_t fileNum));
DEFINE_HOOK(DeleteFile, void(uint32_t fileNum));
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
void ModInternal_ExecuteAudioInitHooks();
#ifdef __cplusplus
}
#endif
File diff suppressed because it is too large Load Diff
+47 -26
View File
@@ -1,5 +1,6 @@
#pragma once
#ifdef __cplusplus
#include "GameOverlay.h"
#include "Lib/ImGui/imgui.h"
#include "Console.h"
@@ -14,7 +15,8 @@ struct GameAsset {
namespace SohImGui {
enum class Backend {
DX11,
SDL
SDL,
GX2,
};
enum class Dialogues {
@@ -35,6 +37,10 @@ namespace SohImGui {
void* window;
void* context;
} sdl;
struct {
uint32_t width;
uint32_t height;
} gx2;
};
} WindowImpl;
@@ -48,10 +54,11 @@ namespace SohImGui {
struct {
void* event;
} sdl;
struct {
void* input;
} gx2;
} EventImpl;
extern WindowImpl impl;
using WindowDrawFunc = void(*)(bool& enabled);
typedef struct {
@@ -59,39 +66,53 @@ namespace SohImGui {
WindowDrawFunc drawFunc;
} CustomWindow;
extern Console* console;
extern Ship::InputEditor* controller;
extern Ship::GameOverlay* overlay;
extern bool needs_save;
void Init(WindowImpl window_impl);
void Update(EventImpl event);
void Tooltip(const char* text);
void EnhancementRadioButton(const char* text, const char* cvarName, int id);
void EnhancementCheckbox(const char* text, const char* cvarName);
void EnhancementButton(const char* text, const char* cvarName);
void EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false);
void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = false);
void EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue);
void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false);
void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector<std::string>& items, int defaultValue = 0);
void DrawMainMenuAndCalculateGameSize(void);
void RegisterMenuDrawMethod(std::function<void(void)> drawMethod);
void AddSetupHooksDelegate(std::function<void(void)> setupHooksMethod);
void DrawFramebufferAndGameInput(void);
void Render(void);
void CancelFrame(void);
void ShowCursor(bool hide, Dialogues w);
void BindCmd(const std::string& cmd, CommandEntry entry);
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled=false, bool isHidden=false);
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha=false);
int ClampFloatToInt(float value, int min, int max);
void RandomizeColor(const char* cvarName, ImVec4* colors);
void RainbowColor(const char* cvarName, ImVec4* colors);
void ResetColor(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha);
void DrawSettings();
Backend WindowBackend();
float WindowRefreshRate();
std::vector<std::pair<const char*, const char*>> GetAvailableRenderingBackends();
std::pair<const char*, const char*> GetCurrentRenderingBackend();
void SetCurrentRenderingBackend(uint8_t index, std::pair<const char*, const char*>);
const char** GetSupportedTextureFilters();
void SetResolutionMultiplier(float multiplier);
void SetMSAALevel(uint32_t value);
std::vector<std::pair<const char*, const char*>> GetAvailableAudioBackends();
std::pair<const char*, const char*> GetCurrentAudioBackend();
void SetCurrentAudioBackend(uint8_t index, std::pair<const char*, const char*>);
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled = false, bool isHidden = false);
void EnableWindow(const std::string& name, bool isEnabled = true);
Ship::GameOverlay* GetGameOverlay();
Ship::InputEditor* GetInputEditor();
void ToggleInputEditorWindow(bool isOpen = true);
void ToggleStatisticsWindow(bool isOpen = true);
std::shared_ptr<Ship::Console> GetConsole();
void ToggleConsoleWindow(bool isOpen = true);
void DispatchConsoleCommand(const std::string& line);
void RequestCvarSaveOnNextTick();
ImTextureID GetTextureByID(int id);
ImTextureID GetTextureByName(const std::string& name);
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
void ShowCursor(bool hide, Dialogues w);
void BeginGroupPanel(const char* name, const ImVec2 & size = ImVec2(0.0f, 0.0f));
void EndGroupPanel(float minHeight = 0.0f);
}
#endif

Some files were not shown because too many files have changed in this diff Show More