Coder Social home page Coder Social logo

sheep-y / modnix Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 7.0 2.43 MB

Mod loader and manager for Phoenix Point (Game).

Home Page: https://www.nexusmods.com/phoenixpoint/mods/43

License: MIT License

C# 95.17% Batchfile 0.05% JavaScript 4.77%
mod-loader mod-manager phoenix-point wpf-application

modnix's People

Contributors

sheep-y avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

modnix's Issues

Modnix 2: PPML mods throws error on load

Reported by Sangvis Ferri on Discord.

System.TypeLoadException: Could not resolve the signature of a virtual method
at (wrapper managed-to-native) System.RuntimeType.GetMethodsByName_native(System.RuntimeType,intptr,System.Reflection.BindingFlags,bool)
at System.RuntimeType.GetMethodsByName (System.String name, System.Reflection.BindingFlags bindingAttr, System.Boolean ignoreCase, System.RuntimeType reflectedType) [0x0001b] in :0
at System.RuntimeType.GetMethodCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00010] in :0
at System.RuntimeType.GetMethods (System.Reflection.BindingFlags bindingAttr) [0x00000] in :0
at Sheepy.Modnix.ModLoader.CallInit (Sheepy.Modnix.ModEntry mod, System.Reflection.Assembly dll, System.String typeName, System.String methodName) [0x00053] in <42da46d68492440ca687016167ebcc10>:0

Elevation needed

Whenever I try to launch the game through Modnix I get this error
System.ComponentModel.Win32Exception (0x80004005): The requested operation requires elevation
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at Sheepy.Modnix.MainGUI.AppControl.LaunchGame(String type)
How do I fix this?

Delete mod does not delete mod folder

If a mod is placed in a subfolder, delete mod only deletes the dll or the mod_info.
In the later case, the dlls may still be detected and loaded in the info's place.

Modnix should detect this case and prompt for folder deletion or file deletion.

Modnix 3 Roadmap

Backport to 2.x:

  • Complete API tests.
  • Safeguard config save (#25)
  • Multiple requirements of same id should be "or".
  • Avoids field, like a reverse Disables.

Must Do, Beta 1:

  • Drop deprecated features.
  • Action mods (#26)
  • New run-once phases HomeMod, GameMod, GeoscapeMod, TacticalMod.
  • New repeated phases HomeOnShow, GameOnShow, GeoscapeOnShow, TactialOnShow.
  • New repeated phases HomeOnHide, GameOnHide, GeoscapeOnHide, TactialOnHide.
  • Api should return Exception on error (not null, not thrown).
  • Migrate Newtonsoft to ModLoader. (Depended by Updater.)
  • Remove old fallback code when MainMod failed to patch. Too many phases to fallback now.
    The new phases hook to MenuLevelController/HomeScreenView, GeoLevelController/GeoscapeView, TacticalLevelController/TacticalView

Must Do, Beta 2:

  • Change reset config to undo edit. Make real reset prompt for config deletion. Tried. Not intuitive.
  • Double check mod action order.
  • Update mod load order in GUI.
  • Add "name" and "url" to requirements.
  • Use Unity Doorstop to avoid repatch.
  • Split ModResolver from ModScanner, and moves mod lists back to ModLoader.
  • Action mods (#26)
  • Mod collections.
  • "Library" flag, self-disable when no mods depends on it. Async flag in Modnix 4.
  • "UnloadMod" phase, to be executed before reload. Its existence means the mod can be reloaded.
  • Detect outdated ModLoader and reports Need Setup or whatever.

Must Do, Gold:

  • Installer will self restart in admin mode.
  • Support GoG Launch.
  • Strip nexus postfix on mod install.
  • Fix js mod cannot have bracket.
  • Enumerate dll and action files for last update time.

May be:

  • A way to toggle dev channel update.
  • Markdown doc support, which is already used for changelog in my mods.
  • BBCode doc support for easy reuse of Nexus description.
  • Mod config dropdown with delete config.
  • Split Manager config from Loader config.
  • Write GUI log to file, and keep a few log backups.
  • Refactor log code.
  • Select All, Copy, Cut, Paste popup on all text boxes.
  • Add / Copy / Delete / Enable / Disable popup on mod list.

Gave up, too many changes:

  • Dark Theme?
  • High resolution timer and time format config.
  • API to load assembly; the assembly will be counted as part of the caller.
  • New loader config to control resolve loop, like phase, library, avoid, disables etc.
  • Api events, e.g. before phase, after phase, mod loaded.

Tweaks:

  • Linkify mod contacts.
  • Add ppml to long modnix status.
  • Rename MainGUI to Manager.
  • Rename ModLoader to Loader.

Refresh mod button does not work

  1. Launch Modnix v0.80, wait for mod list to load.
  2. Add a new mod manually, such as Skip Intro 2.0, or delete them manually outside of Modnix.
  3. Click refresh button, new mod does not show up.
  4. Launch game, mod is loaded.

Expected: mod should show up on step 3.

Fails to inject

Hi Sheep-y,

Nice to see you around PP too (know some stuff of you for HBS Battletech :-))
I believe Modnix is only meant to be used with Epic but as the Year One Edition for GOG just released, i had to try (PP really needs some UI-issues fixed..) However i get the following error when trying to patch:

05:43:22.2000 Thread6┊Running at E:\GOG Galaxy\Games\Phoenix Point Year One Edition\PhoenixPointWin64_Data\Managed : E:\GOG Galaxy\Games\Phoenix Point Year One Edition\PhoenixPointWin64_Data\Managed\ModnixInjector.exe /y
05:43:22.5204 Thread6┊Standard out: Modnix Injector 2.5.3.0
----------------------------
Cinemachine.dll backed up to Cinemachine.dll.orig
Injecting Cinemachine.dll with Sheepy.Modnix.ModLoader.Init at Cinemachine.CinemachineBrain.OnEnable
Found 36 IL instructions in OnEnable.
Injecting before last op IL_0086: ret
Writing back to Cinemachine.dll...
ERROR: An exception occured: System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

I'm not really understanding your injector code, so i thought maybe you're still active and can update for the GOG-version, too?
Thx a lot, best regards, Mad

Modnix 2.3 Roadmap

GUI

  • Fix reset not updated after deleting config.
  • Ctrl+S in config editor
  • Home, End, Ins, and Del in mod list.
  • Delete old mods, and note dups should be deleted. Migrate config too? Overwrite? What about mod set? Too much for a minor update.
  • Tune down runtime warning notice.
  • Remember last app position.
  • Prompt result on manual check update.
  • Change log to monospace font.
  • Accept value output type for registered api, such as bool.

Common

  • Delete JetBrains.Annotations.dll if exists.
  • Rewrite File.ReadAllText and ReadAllLines with read only right to get around write lock.

Loader

  • Fix mod parser not using correct game version.
  • Apply mod priority config.

Api

  • Assembly/Assemblies api should support ppml.
  • Remember original (unwrapped) method.
  • Revise log loops.

Faster injection detection

Mod injector can test only known classes to speed up injection discovery. The chance of PPML being updated to mod another class is low.

Also test multi-thread cecil scanning. If success, speed can be gained without losing forward compatibility.

Config panel sometimes not work

Sometimes the sandbox throws error and cause the config to fail to show up.
I am guessing this is a sandbox lifecycle / gc issue.

03:51:39.1630 GUI┊Showing conf. Editing
03:51:39.1630 GUI┊Sandbox loading 1 dlls.
03:51:39.1832 GUI┊System.Runtime.Remoting.RemotingException: Object '/178f7676_0ee1_4998_9f58_e95738c68d81/qpgavjdyi8hj_emh0tfyutup_3.rem' has been disconnected or does not exist at the server.
at Sheepy.Modnix.MainGUI.Sandbox.LoadDlls(String[] paths)
at Sheepy.Modnix.MainGUI.GridModItem.GetConfigFromSandbox()
03:51:39.1832 GUI┊System.Runtime.Remoting.RemotingException: Object '/178f7676_0ee1_4998_9f58_e95738c68d81/qpgavjdyi8hj_emh0tfyutup_3.rem' has been disconnected or does not exist at the server.
at Sheepy.Modnix.MainGUI.Sandbox.get_Domain()
at Sheepy.Modnix.MainGUI.GridModItem.GetConfigFromSandbox()
at Sheepy.Modnix.MainGUI.GridModItem.BuildConfig(FlowDocument doc)
at Sheepy.Modnix.MainGUI.GridModItem.BuildDocument(ModDoc type, FlowDocument doc)
at Sheepy.Modnix.MainGUI.MainWindow.RefreshModInfo()

Provide data api for getting shared data, locks, and game data

Example:

api( "data sheepy.config" ); // Get a shared data
api( "data sheepy.config", ModConfig ); // Set a shared data

api( "data lock", "harmony" ); // Get "harmony" lock
api( "data rlock", "harmony" ); // Get "harmony" read lock, disposable style
api( "data wlock", "harmony" ); // Get "harmony" write lock, disposable style

// api( "data def PhoenixFacilityDef", "08a852ce-a6b6-3d84-cae6-302032199fca" ); // Access Lift Facility

Give mod a way to check last Exception

Currently, api returns null on any and every error, making it impossible to tell what was wrong.

The api should gives mod a way to get the exception.

This will also allow the GUI to display config reading / writing errors.

I figured out how to install mods on Linux/Steam

Hi,

So to install mods on Phoenix Point: Year One Edition on Linux using Steam, I worked out some instructions:

(Obviously make sure you run the game once before doing this. Also, use proton 5.21-GE-1 or proton 6.0-GE-1 to run it. Later versions might work as well.)

  1. Download https://github.com/Sheep-y/Modnix/releases/download/v2.5.5/ModnixManualSetup_v2.5.5.7z (or a later version, make sure it's the manual setup one)
  2. Extract the files in the Managed folder in the 7z file (3 DLLs + 1 EXE) to steamapps/common/Phoenix Point/PhoenixPointWin64_Data/Managed (no files are replaced)
  3. Extract the file Modnix.exe to steamapps/compatdata/839770/pfx/drive_c/users/steamuser/My Documents/My Games/Phoenix Point/Mods (you need to create some of those folders)
  4. Install mono and basic assemblies, version does not matter
  5. Open a terminal to steamapps/common/Phoenix Point/PhoenixPointWin64_Data/Managed
  6. Run mv System.dll System.bak
  7. Run mono ModnixInjector.exe
  8. Run mv System.bak System.dll
  9. Download mods from nexusmods.com and extract them in steamapps/compatdata/839770/pfx/drive_c/users/steamuser/My Documents/My Games/Phoenix Point/Mods

This works for me. I'm posting these same instructions to protondb.com now, and linking to this ticket. People will probably come here for help.

Stuck at Status: Busy after the latest game update (Orryx 1.10 EGS)

Modnix Log 2021-02-03 07-16-10Z.txt

I'm trying with Modnix v3b2, both the installer and manual setup produce the issue. The log is from the manual one. This is a fresh install, no mods installed/loaded.
Game version is Orryx 1.10 EGS. I have tried the troubleshooting guide (restart, verify/reinstall the game, disable antivirus, run everything as admin).
OS is Windows 10 Version 20H2 (OS Build 19042.746), with the latest stable channel updates.

After launching as Administrator, the Status is stuck at busy, and I get this exception (full log attached):

07:16:06.9035 Thread4┊Loader┊GameVer1: opcode 2 <> 8
07:16:06.9045 Thread4┊System.ArgumentNullException: Value cannot be null.
Parameter name: input
at System.Version.Parse(String input)
at Sheepy.Modnix.MainGUI.AppControl.CheckGameVersion()
at Sheepy.Modnix.MainGUI.AppControl.CheckStatus()
07:16:07.1762 Thread4┊Creating sandbox

After this nothing happens, waited ~10 minutes.

pp-raw-recruit is not loaded

Reported by Sangvis Ferri on Discord.

It seems that pp-raw-recruit is detected but its initialisation method is not being called.

Version 1.0 Roadmap

Ver 0.60 Preview

  • Implement setup.
  • Test PPDefMod compat.
  • Implement update checker.

Ver 0.70 Preview

  • Implement mod meta parsing.
  • Improves and document troubleshoot.
  • Implement mod list and basic info.
  • Implement delete mod.

Ver 0.80 Beta I

  • Remake icon.
  • Rename setup to installer to sort better in download list.
  • Allow operations in case of "both".
  • Implement Harmony 1.2 bridge. Did my best. Not working.
  • Open modnix location instead of launching directly.
  • Implement mod_info.js parsing.
  • Implement Phase.
  • Implement dynamic init parameter.
  • Implement game / modnix / ppml version checks.
  • PPML v0.2 compatibility.
  • Button icons.

Ver 0.90 RC

  • Better Detect EPG path.
  • Full mod Info, not stub.
  • Implement add mod (dll).
  • Implement add mod (zip).
  • Implement add mod (7z).
  • Ignore entry points with Obsolete attribute. Leaving as a way for future loader to be backward compatible.
  • Deterministic mod loading.
  • Mod settings.
  • Switch Modnix to json based settings.
  • Auto game status refresh
  • Change setup game path
  • Change manager game path
  • PPDefModifier compatibility when adding mod.

Ver 1.0

  • All-purpose mod interface.
  • Support resource mod_info (instead of embedded resources)
  • Select newly added mods after add mod. Not straight forward. Skipping.
  • Update Documentation.
  • Videos
  • Lots of testing.

Version 2.0 Roadmap

A quick update to solve some pressing needs before the code is changed beyond recognition.

Well, there are more "pressing needs" than expected. More efficient to finish them and test.

  • Fix dll type instance sharing.
  • Add mod api action config_save.
  • Add mod api action assembly.
  • Implement game path api.
  • Allow mods to add to api. Conflicts will ignore all. First come first serve.
  • Add console log
  • Add change log.
  • Auto-refresh log.
  • Plain text log filter.
  • Warn when default config does not match new config.
  • Parse log for mod errors.
  • Parse console for mod errors.
  • Config editor.
  • Show release, license, unlicense, changelog, readme.
  • Enable / Disable mod.
  • Zip embedded libraries to reduce installer size.
  • Click on notice to jump to mod.
  • Mod priority.
  • Update PPML to v0.3.

Some more issues during testing:

  • Keep current selection on mod list refresh.
  • Show (dev) when on dev update channel.
  • Scan all game bar locations instead of relying on guid.
  • Auto-refresh mod list on loader log update.
  • Linkify game path.
  • Sort mod load order by phase.
  • Test mod notices with touch and stylus.
  • Linkify mod path.
  • Live json syntax validation for config.
  • List supporting docs in mod_info.
  • Skip update check when on metered connection. Too complicated outside of UWP.

Version 1.11 broke the mod?

I'm using assorted adjustments and some things appear to be broken. Base building and aircrafts now have 'NEED TEXT' popups on them.

Error when adding empty 7z

empty.zip

System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex
at System.String.Substring(Int32 startIndex, Int32 length)
at Sheepy.Modnix.MainGUI.SevenZipArchiveReader.<>c.b__4_1(String e)
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Sheepy.Modnix.MainGUI.SevenZipArchiveReader.ListFiles()

Error when loading config

Reported by JulianSkies on NexusMods.

Logs:
ribi2TeM.txt
yDK9SMpK.txt

Translated:
Could not load file or assembly 'file: /// C: \ Users \ Oran First Ignition \ Documents \ My Games \ Phoenix Point \ Mods \ Modnix.exe' or one of its dependencies. Unsupported operation. (Exception from HRESULT: 0x80131515)
Filename: 'file: /// C: \ Users \ Oran First Ignition \ Documents \ My Games \ Phoenix Point \ Mods \ Modnix.exe' ---> System.NotSupportedException: Attempt to load an assembly from a location network that would make the assembly safe in previous versions of the .NET Framework. This version of the .NET Framework does not enable CAS policy by default, so loading it can be dangerous. If he does not intend to place the assembly in a restricted area, enable the loadFromRemoteSources option. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
em System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
em System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
em System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
em System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)
em System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
em System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)
em System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
em System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
em Sheepy.Modnix.MainGUI.Sandbox.CreateSandbox()

Config save failure can crash Modnix

When config save fails, such as blocked by an anti-virus, Modnix will crash exit.

Config is saved for many operations, so it should be fixed.

Modnix 4 Roadmap

Must Dos

  • Draw activity diagrams and system diagrams.
  • Refactor code - use more local functions.
  • Refactor code - rename files to better reflect purpose.
  • Refactor code - integrate settings with main manager.
  • Refactor code - normalise manager-gui communication.
  • Refactor code - rewrite gui state to be more event driven.
  • Refactor code - switch manager to mod api for config management.
  • Refactor code - revise all mod info access.
  • Multi-thread mod parsing.
  • Separate mod loader logger from mod logger so that each mod can have own log level.
  • Right-click menu on mod list and editor.
  • Verify Mod Loader version, and perhaps injector / cecil version while we are at it.

High Priority

  • Modnix and Per-mod settings panel - manual disable, log level, language, update flags, raw mod_info and override.
  • Replace community buttons with dropdown on collapse.
  • Review keyboard tab order.
  • Mod profile, e.g. Skip Intro can have Intro only, Default, Default + Skip New Campaign.
  • Switch setup path / bypass launch for setup.
  • Split AppAction from ModAction.

Medium Priority

  • Mod lifecycle to support in-game on/off.
  • Use System.ComponentModel or System.Configuration attributes to annotate config class.
  • Modnix config can be read at the same time as mod scanning, but before mod resolve.
  • PPML version switch.

Low Priority

  • Animate modnix icon.
  • Pack Harmony and Cecil in Loader to further reduce exe size.
  • Vortex integration?
  • UUM support?
  • Check nexus / github for mod updates.

Some users need to unblock Modnix to be able to see/edit Configuration

I use the excellent option to have a class in my Assembly that Modnix parses to provide the configuration view for editable settings.
I had many posts on nexus on how to configure "Assorted Adjustments", it seems that quite a lot of users need to "unblock" Modnix for the Config-Tab to be shown at all.
It's fixable on the users side following this guide: https://stackoverflow.com/questions/28339116/not-allowed-to-load-assembly-from-network-location
but if possible would be better to workaround/fix on programs side as fiddling with .NET settings isn't really reliable for the end-users.
I can't provide more details, unfortunately, as i never had the issue myself. I'll point people to this issue though, if you're fine with that?
Thx alot and best regards, Mad

Action Mod Roadmap

Planned for Modnix 3 (#23).

Modnix 3 Beta 1

  • Expand mod_info to allow a Dictionary[] Actions field.
  • Implement framework to allow mods to process Actions. (let's call it RunAction).
  • Actions should add caller prefix to handler logger.
  • Hide duplicate load log.
  • All actions have Phase and OnError.

Modnix 3 Beta 2

  • Make configurable. Pushed to Modnix 3.5 with config presets.
  • Allow API to find caller. Required to use the correct session. Need to bound caller to thread since API is thread-safe.
  • The "Include" field runs Actions from another file, relative to the current file or absolute to the mod's folder.
  • Update PPDefModifier to support action through include.
  • Allow action mod to load library. Keep it simple. Between Modnix and Scripting Library, if a mod need something more it shouldn't be an action mod.
  • Supports actions with the "Guid"/"Cls" field, and evaluates it like PPDefModifier. PPDefModifier has been updated and there is no need to have its cake.

Scripting Library Beta 1

  • A new mod bundled with Modnix.
  • Each mod have their own eval session, preserved between phases.
  • Provides the "eval.cs" api to evaluate c# code.
  • Provides the "pp.def" and "pp.defs" api for quick lookup of game def by guid, path, or type.
  • Supports actions with the "Eval" field, and evaluates the code on the fly.
  • Provide data cache for type/name/path.
  • Helpers to aid in modifying weapon, research, facility data. Weapon done, the rest need more ideas.
  • Pre-load script evaluator in background.

Scripting Library Beta 2

  • A way to allow mod to add helpers.
  • [ ] Rewrite helpers to supports mod unload. Things get messy when multiple mods modify the same data. No good fix I can see.
  • Use caller mod for API eval context.
  • A helper to get tactical item with tag(s).
  • Update dependent libraries.
  • Try to solve the assembly reference issue again to avoid dll copying.

GUI does not care whether game is running

  1. Launch game.
  2. Run Modnix. Modnix says game is running.
  3. Mods can still be deleted and game can still be launched. Or try to.
  4. Quit game. Modnix does not automatically detect it.
  5. Click Refresh. Status change to Injected.
  6. Launch game and Alt+Tab. Modnix does not detect that game is running.

Lastest mod not always prioritised

When multiple mods of same id exists and all but one must be disabled, their LoadIndex would be compared first, instead of Version first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.