#Toggle Notifications devlog
1 messages · Page 2 of 1
heh
I loved making Starship flight test KOS scripts
figuring out how and why things work
it was explosive to do so
i liked doing it on mun
SN5 hop was a challenge, dealing with the offset thrust
AssetManager.GetAsset<Texture2D>($"{SpaceWarpMetadata.ModID}/images/icon.png") <<< that
was causing all the issues
AssetManager.GetAsset<Texture2D>($"{MyPluginInfo.PLUGIN_GUID}/images/icon.png"), <<< is what i needed it to be
Ayyyee
thats just a spacewarp error, you are safe to ignore
not really, that should not be happening if you have your swinfo.json set up correctly afaik
though I don't see anything wrong
possibly either remove the "version_check" property or fill it out
or maybe I'm just remembering how SpaceWarp 1.2 will do it and this is normal in 1.1, can't say I remember
im gonna get going to bed but still got a few things to work out with it
havent gotte GUI working but focused on making sure everything loads correctly
https://github.com/cvusmo/Toggle-Notifications everything new is updated but no new release
so now i have zero GUI lol
what are u trying to do?
make tabby tabs that have names on them
to tab between things
so i can be like "solar panel tabby"
because each notificatoin has a bunch fo stupid messages attached to it
also doing more than i really need to do because im trying to learn as much as i can
so yes it may be overkill, but im learning a lot
so yeah i have this error and i dont know how to fix it
hmmm
i have a good tutorial on that a sec
will take a bit of programming tho
In this video we take a look at how to build a Tab System for a UI Menu. We create a flexible Tab Group and Tab Button behaviour system that allows to easily switch between GameObjects or execute custom code when a Tab in the group is activated or deactivated.
Be sure to LIKE and SUBSCRIBE if you enjoyed this guide! Share the video for extra l...
heck yeah
the thing im getting confused on
with 90% of this, is which api i should use, spacewarp, bepinex, unity
note that he's doing this inside of unity (which u can also do)
like where the heck does unity gui come from
but this can all be done only via coding too
thats good
the goal
is to create a gui that has tabs
and each tab correlates to various notifications
btw if you want, you can create the UI in Unity and then import it in game
@timid quail knows a bit more about that than i do
hm
importing IMGUI
Wait what?
yes, you create the prefab and then instantiate it
just pack it in a asset bundle
Doesn't it have only a C# API?
i mean yeah thats how most games build their UI xD
Wait, the default unity ui is IMGUI right?
No, not really, IMGUI is a debugging tool
Ok im dumb then
but it still applies, you can build the UI on unity and then import it in game
Yeah, in that system, it's what the game uses
But no KSP1/KSP2 mod has used it afaik
UITK is a better option for this imo
hm
yeah but if you build a more complex ui i think its better to build it in unity
this^
where do i find UITK?
#1085537097714245662
ah
But it's not really production-ready
no worries
i think i can get it working
which i really want to do it hardcoding and brute forcing my way through it
it helps me learn how this all works
or mainly how it doesnt work
ive found 900 ways it doesnt work so far
I mean you can ask here: #1091863665134796880 message
they just finished making a tabbed UI
thats what ive been uising
using
im trying to figure out why i cant convert the status type to the unityengine.guistyle
because this class is entirely all about style and working with the guistyle
so im reading, which is what ive done a lot of this week
so, basically, BepInEx only provides a config API, SpaceWarp provides some abstractions over the game's code such as appbar buttons, asset loading, etc, and Unity provides all the generic non-KSP-specific stuff
and the rest is just the game code itself
ohhh
so that means i need to cater to what each API does best
and if it doesnt apply to that API, then use a differenet API to get the result i want
pretty much
im over here using plungers to build a house
as for the tools provided by cfloutier, schlosrat, etc, I can't really help with those, you'd have to ask them
is this commented out stuff what you were having issues with?
yeah
well
its future stuff
i wanted to first get what i had working
then work on adding the commented out stuff
ive got cfloutier and scholsrat helping
next week theyll have more time so im just trucking along
found it
this is what i need to access instead of making my own
on the right trakc now
That yandere simulator type copy paste tho aaaa 
ah... the satisfaction of organized code thats repetitive. also i have a horrible memory so i keep forgetting what ive named things
hookedonC#worked for me
Update: all i need to do is get togglenotificationsui.cs and selection.cs working together.
I can't imagine why you'd think that, but I do know this. Where most people may say "if it's not broke, don't fix it" I believe most modders would say "If it's not broke, it needs more features".
It's almost ready
I NEED this mod! I’m really getting sick of useless notifications popping up on my screen…
ayeee it's almost there lol. i just uploaded v0.2.0-alpha build, finishing getting GUI stuff working with the plugin, then testing today
its taking time because im learning all of this as im doing it. but FP has been essential in helping me stay on track. ive just overcomplicated things a bit. finally got it simplified. so im hoping today to be able to post a .zip here to test before release
ALMOST ready for a test
jus tneed to make converttomessagecentermessage an actual thing
v0.2.0-alpha ready for testing. be warned, I haven't tested this so it may not even work and show gui
Still didn't get gui working but I did get each notification to be toggleable, sorta?
@opal lagoon @tiny oasis when you both get a chance take a look at logs and help point me in the right direction 🙏
There's nothing I see in the KSP.log that gives any clues, but in the BepInEx log it seems you've got something going on in TabPages at line 37 that's giving you a StackOverflowException.
Why are you trying to make a tabbed GUI for your mod?
I've sorted through multiple issues so far
Right now I'm struggling to get the appbar to register
I'll re-upload what I'm using now to github
Because it seems fun to do
And I'm learning a lot
What's the role of the mod config variables?
That's what turns the notificationevents on and off via harmony patch
Then why do you need a GUI?
BTW, have you ever had an issues where selecting the docking port as the target was a pain?
That last question is unrelated to your mod, FYI
Cause now you can target docking ports from a menu!
Github is updated with what I'm working on
Yessss!!! Thats epic af
I don't need. I want because it's called toggle Notifications and I want the player to be able to toggle them lol
Also I want to learn how to code the gui and make it work
If I were you I'd roll all the way back to a really basic one page GUI and put toggle buttons on it. Really, just make it simple.
When that's working you can build up as needed.
I've only got tabs because (a) cfloutier made them, and (b) I've really got way too much stuff for one page
True
I have pages for each notification mainly for curiosity
The end result will probably be 2-3 tabs Max
How much info do you have on each page?
But for now experimenting with how it works
It's just a toggle button on each tab
I just wanted to see if I could make separate tab pages
So I knew how they worked
With a very basic layout
Cause it's the same thing 5x
But I can't get the appbar to load
In my (very limited) experience, if the app bar doesn't load then most often something crashed in OnInitialized before it got to the code that puts the app bar button on there.
Do you happen to have a Hot Key to also launch?
You may be able to get the GUI up with that even without the app bar button
though that won't solve this problem
No hot key
I've never had any luck getting the debugger to stop inside OnInitilzed as it's running so damn early
Hmm
So, litter the thing with Logger prints!
Seriously, you may be able to isolate the offending line that way
That's true
So far I've been able to figure it out with the stack overlay errors
It's usually something I forgot or had that I just didn't need
Doing it now though
Also thinking of removing everyone else's mods to make the logger easier to read lol
I often pare down to the minimum set while debugging for that reason. Also, it ensures that any issues I notice are either internal to the game or in my code.
Also this helped. I had an issue in oninitialized that was screwing stuff up and a few other issues relating to the settings.json
Congrats! Well done!😄
now its just a matter of getting it setup and probably going to have to create some new GUI elements
what controls the Allow plugin to run on every frame... Update?
this all makes sense now
@opal lagoon for the life of me I can't get this error fixed. I've reworked the assetsloader, I've gone through every single line in every single namespace and class but i can't figure out why the heck this isn't loading the very first png "window.png"
well it was window and now its the icon
this is the current assetsloader.cs
So the ConfigurationManager checks settings and will return this if your settings didn't load
Path.Combe(Paths.ConfigPath, was causing my settings.json to save in the config file. Changing it to Paths.PluginPath fixes the issue
now the mod should load settings properly
so many little things can make everything go wrong so quickly lol
finally
Why have you got the Allow Pluginto run on every frame set top dsiable?
Have you tried swithcing that on?
Also, what is line 15 of Selection.cs doing? Whatever it is, there seems to be a NRE there
Is TN now working? Is that what you're showing in this screen grab? If so CONGRATULATIONS! I've never done a Harmony patch mod, so I'm not really sure what I'm looking at here.
it sort of works? the patches get implemented from my best understanding of how its working, now fine tuning the gui to function correctly.
but harmonypatch could be completely wrong and i may need to scrub it and use a different method to disable notifications
Can it prevent notificiations?
not sure yet
theoretically it is working
but its not
so for example when i click pause
it still dispplays the gui
Simple. Have a test sat with solar panels and watch as the mofo flys around into the shadow of Kerbin
I'd love to never see that particular notification again
Sure, just simulating an extremely low kerbin orbit...
right now im trying to get teh stupid game paused to go away correctly
i think my core issue is this
Configuration Manager not assigning the PropertyInfo to my plugin to allow the plugin to run on every frame
Why have you got it disabled?
its never been enabled
and i have zero idea on how to fix that
cause when i click on disabled it doesnt change, just like when i click on anyone elses' mod who has it enabled, clicking on it will not change the value as its hardset in configuration manager once its loaded
Interesting.
thats the class that deals with "allow plugin to run on every frame"
i just dont understand how this works and why my mod is being thrown into the else category
it clearly says modsWithoutSettings
Start a new mod using the spaceward template
which means my settingsfile and configfile are borked
so how do i get all of this that ive worked on into a fresh mod?
Then bring the harmony patching crap int the new mod after you're user it doesn't get set this way
ah
I'd use copy/paste, but that's up to you. retyping it all works too
use a fresh mod to see if it does anything
😛
Seriously. Start a new one called TestMod or whatever
LOL
Get it up as a shell with a stupid simple GUI that does squat
i literally named it that
Perfect. Once you see that this stupid setting is correct, then chunk-by-chunk move the methods and data from the old mod into the new one.
Test each time you more some more in and it can compile
that makes sense
If this stupid setting goes to disabled again, you'll have found what did it
figures out where it broke
can I see your current main plugin class?
yup
so a few errors in my original plugin
need to use the template method for the appbar and then use the assetloader to load images internally but not use it to call it outside of the plugin
hard lessons but im learning. i appreciate all of your guys input and patience with me
i think im learning how it all works and why
painfully though lol
alright so the cause for your plugin having the "Allow plugin to run on every frame" option disabled appears to be because its OnDisable method gets called, which sets the MonoBehavior's "enabled" property to false which then gets picked up by the config manager, but no clue why just yet
well I worded that badly
rather the OnDisable method gets called bacause the MonoBehavior gets disabled, the other way around
no line, I have no clue where this happens
I just know it does, because your "OnDisable" method runs during the loading of the plugin
yeah, the component is the only one that is disabled by BepInEx for some reason
LUL
and when I do enable it manually, I get exception spam
(though this is from the 0.2 version from CKAN)
if you could get me a test build of 0.3 (or even push the code to a dev branch on GitHub for me to compile), I'd be glad to look into it more
will do
thats the current version that im working on
well one thing i messed up...
it will never display a GUI because currentState can't change until the GUI is showed
awesome, taking a look at it now
appreciate it
well, problem solved
you apparently renamed your ModID from toggle_notifications to ToggleNotifications but didn't change the name of the template folder, so your swinfo.json file doesn't get copied from there into your build folder
and SpaceWarp automatically disables any mods that inherit from BaseSpaceWarpPlugin but don't have a swinfo.json file
also, two small errors I managed to find: you have a field called configFile but you never assign any value to it, so it's null, and then you try to call methods on it
so in Awake, replace configFile.Bind(...) with Config.Bind(...) (and anywhere else you might be using it)
Config is a property already provided for you by BepInEx
in BaseUnityPlugin (which BaseSpaceWarpPlugin inherits from, and so by extension also your mod)
and don't call TNStyles.Init() in Awake, it relies on SpaceWarp already being loaded which it isn't at that point so it causes an exception, you can move that into OnInitialized probably
also I don't think there's any need to initialize it multiple times per frame inside OnGUI, so I'd delete that call from there as well
all those steps combined got rid of all the loading exceptions + the "enabled" bug for me
glad to help
by the way, I just wanted to ask - is there a specific reason why you made a new repository instead of just making a new branch in your old one?
i forgot i changed from v 0.2.0 to v 0.3.0 lol
also
brain farted and just made another repo
Toggle Notifications v0.2.1 devblog
current build: https://github.com/cvusmo/Toggle-Notifications/tree/Toggle-Notifications-0.2.1-alpha
To do this week:
-Fix GUI bug causing GUI to be closed. Error is in plugin coding.
-Organize and create GUI for all notifications
-Verify patches are correctly disabling notifications consistently. Sometimes they do, sometimes they don't.
IF Harmonypatch doesnt work, find another way?
working on GUI stuff
that icon looks good
thank you!
Not sure about the orange but well see
focusing on getting the code condensed, readable, and simple.
then getting the gui working properly
also found a differnt class i need to disable
FINALLY!
we have a window
lots of little mistakes
but finally getting this thing to work
first mod is the hardest right? LUL
I feel like you have gone excessively complex for what it needs lol.
i blame engineering background. im used to building redundancy in everything
coding doesn't really need much redundancy im learning
in fact im pretty sure it makes the code worse if you have far too much redunancy in it
debug log be like "NO"
OnGUI is being called but the object returns a null value
whats on line 220
so i created a list, the list has a dictionary, the get and set search the list, and return a currentState value
and updatecurrentstates updates the actual patch toggle
trying to keep the library to where all it outputs is UpdateCurrentStates and currentStates, so then I only have to use those in my plugin
inside of this where is notificationToggle set?
not that
hm
wheres it getting defined
that is where its being defined?
like string x = "y"
its within the class and the definition im pretty sure is the notificationStates[notificationType] = currentState;
right? am i understanding that correctly?
no lol
inside of ToggleNotificationPlugin.cs notificationToggle where is it created in that file
not this version but ill push it up
please do
I have 4 mins until my next meeting.
no worries
whenever you get a chance to look i appreciate it. ill have it up in devbranch shortly
This is the most recent issues I'm working on. devbranch is the current build im on
https://github.com/cvusmo/Toggle-Notifications/tree/devbranch
• The first error is related to loading a parameter called "path". Path is null, causing an exception in the file-loading process. SettingsFile needs to ensure that the "path" parameter is properly set before loading the file.
• The second error is a HarmonyLib.HarmonyException, indicating an error in the IL (Intermediate Language) compilation. It seems to be related to a method called "OnStateChange" in the "KSP.Game.GameStateMachine" class. Specifically, the error states that a parameter called "stateChangedMessage" is not found in that method. Back to reviewing the code in the "OnStateChange" method and verifying if the parameter is missing or incorrectly named.
• The third error is an error in saving the settings file. It is similar to the first error, indicating that the "path" parameter is null when attempting to save the file. Ensure that the "path" parameter is correctly provided before attempting to save the file.
• The last error is an ArgumentOutOfRangeException, indicating that an index used in the code is out of range. The error occurs in the "TabsUI.Init()" method, specifically on line 71 of the "TabsUI.cs" file.
this.Data = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(this.FilePath));
Uh... I just learned how to use my repo in visual studio and instead of manually uploading I can just push/pull from vs.
mind = blown
FINALLY.
Figured out why window.png wasn't being recognized.
The Build Action property for the png was set to None. It needed to be set to Content for it to build with the solution.
Images are loading properly. GUI isn't fully configured so it doesn't show up. Still need to code the OnGUI etc. Right now debugging the pause patch
Will continue later today with getting harmony patches working correctly.
You've not set what it should patch according to the error ^
That's the fun part. Figuring out what needs to be patched.
Yep
thank you for mentioning that. working on the patches now to get them functional
Toggle Notifications v0.2.2 devblog
@opal lagoon look at the AssistantToTheAssistantPatchManager.cs and the ToggleNotificationsPlugin.cs to see how I used HarmonyPatch to patch correctly. It was simple once I figured out exactly what method to patch.
this is the UI look im going for in game.
Nice! Looks clean and very sharp.
thats a screenshot from the game UI, so im wanting to use it as a template
lol
i like the off / on button idea
LOL!
still haven't figured out how to get ONGui to work properly
Well, you’ve got a look to shoot for then!
but now the pause game notification is gone!
so ill take the w's when i can lol
i did what you said, put a bug of debug logs in
helped tremendously sort it out and getting it functioning
Debug logging FTW!
thanks for all the help so far you're a legend!
Not hardly! Munix and Lux are legends, I’m just a punter hacking my way through stuff. There are some real code artists out there though!
I'm really happy i took on the challenge to do this. learning a lot and it amazes me how some of these guys are so dang good at it
LUL
well, this is the new bug. trying to figure out why this happens. but thats for later today
This didn't patch anything unfortunately. I had to use other classes including notificationevents to disable game pause and solar
was working for me
Hm I'll try it out again but I had no luck with 0.2.0 functioning properly for me
to continue from here: #🔴mod-dev message
it seems unnecessary to me to wrap each Harmony patch in its own class, you can replace this sort of a thing:
[HarmonyPatch(typeof(NotificationEvents))]
public static class NotificationEventsPatch
{
[HarmonyPrefix]
[HarmonyPatch("GamePauseToggledMessage")]
public static bool Prefix(NotificationEvents __instance)
{
Logger.LogInfo("Prefix Loaded for NotificationEvents");
return false;
}
}
with this:
[HarmonyPatch(typeof(NotificationEvents), "GamePauseToggledMessage")]
[HarmonyPrefix]
public static bool NotificationEvents_GamePauseToggledMessage(NotificationEvents __instance)
{
Logger.LogInfo("Prefix Loaded for NotificationEvents");
return false;
}
I don't mean to be rude but 70% of the code in this mod seems unnecessary.
and in ApplyPatches you don't need to target the whole assembly: harmony.PatchAll(typeof(AssistantToTheAssistantPatchManager).Assembly);, when all your patches are in one class, you can just keep harmony.PatchAll(typeof(AssistantToTheAssistantPatchManager));
none taken, ive removed a lot of code as i overcomplicated it. learning a lot and i appreciate any guidance and advice!
debugging. also removed a lot of unnecessary code and if im not using it, ill be deleting it. a lot of what i have from flightplan i probably wont end up using. keeping it just in case
I love it
rm on windows 
Yeah I'm aware
#🔴mod-dev message
90% of time I spend in a CLI is in a Docker container/in WSL, so I wrote that without even thinking about it, and then haven't noticed it for like a month at all 
Will be fixed in the next version of the template which I already have finished and is just waiting for SpaceWarp 1.2 release
How close do you think we may be to SW 1.2?
hopefully within the next few days, the goal was to wait for the finished UI rewrite, but since there are some issues plaguing it, which I don't think we can resolve very easily (plus it doesn't bring anything new or useful for mod developers), we'll probably make that a separate release at some later point
What's new in 1.2? I assume this is not bringing UITK?
well UITK is a separate mod/library, which anyone can use already (though it's far from perfect)
I like it.
hmm
https://github.com/SpaceWarpDev/SpaceWarp/compare/main...v1.2.0 you can see the commits here, but to sum it up:
-
added a specification version property to swinfo.json - leaving this out or setting it to
"spec": "1.0"will basically enable backwards-compatibility mode, and using spec version 1.2 will switch to a backwards incompatible mode, where for example most uses of the swinfo.json property "mod_id" will be deprecated in an effort to transition to only having one unique identifier for each mod, that being the BepInEx GUID (since the SW mod ID is basically a relic of the time when SpaceWarp was a mod loader on its own) - this allows us to make changes which break backwards compatibility without releasing a new major version like SpaceWarp 2.0, because the mod developer has to opt in by changing the spec version to enable those changes, and all old mods will keep working the way they did before -
added support for online version checking from the .csproj file's <Version> property instead of swinfo.json "version" property to support the 1.2 template which automatically generates the swinfo.json from .csproj properties so that all information is only contained in one place and not duplicated (helping us avoid mistakes like updating the version number in the swinfo but not in the project itself or vice versa)
-
updated Colors patch for part mod textures (Lux will have more details on this)
-
added a mod list API
-
automatically generated XML documentation is now packaged with the SpaceWarp NuGet package so that you get documentation for SpaceWarp classes, methods and properties in your IDE
those are the major changes
Is there anything being done that will fix the issue with Alt-M messing with map mode? By this I don't merely mean that Alt-M will toggle you in and out of map mode unnecessarily, but more that it can leave you in a state where the map mode is borked and you can't zoom.
I've never heard of this before, mind writing up an issue about it?
I've tried to replicate it right now but can't seem to be able to trigger that bug
so I would need to be able to get the precise steps that lead to it happening
because just loading an in-flight save and pressing alt+m multiple times (both starting from flight view and starting from map view) doesn't affect map zooming
@opal lagoon how do any of your mods work for GUI? im getting these kinds of errors about the GUISkin
why not just try to build the UI very simply with the native IMGUI methods before trying to switch to a fancy custom UI library?
but now progress, it is Attempting window. so tahts a first LUL
how does your structure of the mod folder you're putting into plugins look?
more specifically, where in it is the window.png file located?
well that's weird
This is the source of all the problems and no matter the path I make it, it doesn't find the assets properly. But it still finds my icon.png fine
at what point does the exception occur?
so on the appbar i get my icon, but for GUI i get nothing
is it after the game is fully loaded?
yeah fully loaded sitting on launchpad chillin
or during or before?
testing it again to confirm exactly where it occurs
so icon loads just fine for the appbar
nothing displays when i activate the appbar button for tn
that's really weird
the "assets" folder shouldn't be a part of the path
patch works
for example this is how I register my app bar button
no it shouldn't but whether i set the path as togglenotifications/images/.... or assets/images/ it still laods the icon.png
https://github.com/cvusmo/Toggle-Notifications/blob/17136bf42d5f83ef2af99fe94ff4cbdd37abcccc/Toggle NotificationsProject/ToggleNotificationsPlugin.cs#L83 this is where you get the icon
you don't use the AssetsLoader class
son of a
so now it makes sense why the icon loads
that makes sense because ive had to slowly make sure things were being used correctly and initalized properly
because you don't have the "assets" part in it
so i got the patches working because i went through and made sure everything was being used properly
but i thought the assetsloader was functioning fine
so in my appbar.rregisterappbutton il need to add a assetloader instance?
like you did
before
a variable?
but I have no clue where it comes from or why it's there at all even
but either way, the AssetsLoader.LoadIcon won't work the way it's written now
so best to just stick with SpaceWarp's AssetManager
so assetsloader isnt even working so i can remove it compeltely from the plugin
now to learn how spacewarps assetmanager works
I mean it's exactly the same, just without the extra debug logs
yeah I mean the KerbonautManagerWindow.IsOpen property is pretty much the exact same thing as your isWindowOpen
where is kerbonautmanagerwindow from?
that's just my class aggregating all the UI code
ah
makes sense now
also think ive messed up a few things with OnGUI and FillWindow
in lazy orbit your fillwindow is full of all the GUI info
if you push all your current code changes to the dev branch (if it's not already up-to-date), I'll take a look at in a bit, just gotta go walk my dog first
no worries ill push it up now
its updated, im gonna take a break, and give my brain a rest for a second. i appreciate you taking a look at it and all the help
if your going through all this effort to use custom imgui components it would be faster to swap to UITK.
i did all of my testing on the launchpad without making sure that when im on the launchpad things will work...
i just realized this and added that gamestate into the onGUI
because its a different state
you dont go in flight until you've launched off the launchpad, and since i have a probe that has no engine that is just sitting on the launchpad
the game sees it as being in the Launchpad state
is that only with launch clamps or something?
nope but now i wanna test and figure out when the game changes the state on the launchpad
so currently untested
well I can't seem to get the Launchpad state when I'm on the launchpad
it says FlightView
dafuq
smol progress. we have a window finally.
but the ongui is being called nonstop and is on an infinite loop.
yeah
mind pushing your latest changes again?
sorry I haven't had the time to look at it until now
nope i got rid of the ongui call though
so it doesnt clog up the log uselessly
also figured out how to use the assetsloader
I see that in your master branch (aka 2.0 I guess) you have the correct path in it
yup
just pushed it
i reverted back to what i was using before as well
I was getting a failed to load image because i wasnt calling it and i didnt understand its as simple as "Texture2D imageTexture = Assetsloader.loadicon("THEPNG");
learning a lot by doing it this way as far as how the API's work with BepInEx, SpaceWarp, Unity, and how simple it really is and i just keep overthinking it
by the way, one thing I'd recommend to you to keep in mind as a beginner would be to pick a code style and stick with it, it makes things much more organized
for example keeping class, method and property names in PascalCase, local variables in camelCase, private fields in _underscoreCamelCase etc
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions here's the code style that Microsoft uses
i hate that _underscoreCamelCase thing
lol
but good to know theres naming conventions
i will use that. im good with rules. i was military for 12 years
and ckan being weird
where is that screenshot even from?
its because i changed my swinfo.json to 0.2.2 in my master and it needed to be 0.2.1
uh where did i find that one sec
super useful and good to look at to make sure whatever you push to ckan goes through
I think the mod pushed it thorugh for me once i fixed the swinfo.json https://github.com/KSP-CKAN/KSP2-NetKAN/pull/47
alright so I took a look at your code and I put together a commit cleaning up the repo because you had like 3 duplicate images folders and the build pipeline wasn't working because of some folder renaming you might have been doing
now it all builds nicely and cleanly altogether from just one source into the one destination folder 😀
https://github.com/cvusmo/Toggle-Notifications/pull/21 made a pull request with the changes
but the major issue right now is that you're trying to access some methods of the field notificationToggle which you never assigned a value to, so it's just null
That's wild!
Thank you for taking the time to do that. Very curious to see what you've done and how I can improve
LFG!
THANK you @timid quail for cleaning the repo up and helping me get this going. I'm going to be referencing the C# coding conventions and for 0.2.3 updating the naming conventions in my mod. but for now, I FINALLY HAVE A GUI
awesome 😆
nailed it... lol
lol
Far easier to make that in photos hopefully. But now I understand I have to code the pixels. Not sure if 10f = 10 pixels?
some light morning reading
Looks like you’re using the K2D2 close button. I think you just need to control where the rect is drawn so that it shows up where you want it. I can check when I get home, but putting that in the right place should not be an issue
big brain
Clever
its because im using topbuttons so i'd have to rework topbuttons.cs to get the topbuttons to display correctly as well as figuring out what to do to create a window within the main window which so far i havenet figured out.
everything is functional. things turn on off with the radiobuttons. the cross exists the mod. so now its getting it properly configured and it could be due to the window being doing in OnGUI instead of FillWindow?
holy crap thats cool. BeginArea to create an area within the window
learning has occurred.
Now to tweak it to make it look better
well, now i need to figure out how to get the in game menu to work again because yeah
@radiant arrow or @tiny oasis any idea where I can find the pause button image that they use in the game?
FYI this is just ez reference for me as im editing the gui
@opal lagoon could you take a look at the dev branch when you get a chance today. i have a weird bug where ESC is disabled and I'm unable to bring up the in game menu by using ESC or even by clicking on the burger.
I can't promis I'll be able to solve it, but if you like I'll be happy to take a look.
no worries. i haven't been able to figure it out yet but wanted to focus on getting the gui built then figuring out the bug lol
now to get the labels for the buttons in the right spot
i thought about making it where the buttons go across the window and say "Pause Notification Enable" and Solar Notification Enable... but i wanna fikgure out how to make the gui
so even though its easier and will probably lok better, im focused on the learning aspect of how it works and why
So... My GitHub foo is a bit weak and I forked your master branch by mistake instead of your dev branch... I'm trying to sort out how to fix that, but I've already made some (unrelated) improvements on your master. Maybe you've already caught these in your dev? You'd pulled in a bunch of icons that were MNC, FP, and K2-D2 specific that have nothing to do with the general GUI and which I don't expect you to ever need. I ditched those and cleaned up your csproj a bit
by the way why is the UI library that your and cfloutier's mods use not a separate library plugin at this point?
Ahh... Ok, I'll try to get onto the dev branch then so this can be useful.
that way you could all avoid duplicating files and classes
no worries. i appreciate the second pair of eyes
An excellent question!
true. would be more efficient but this is also a great way im learning how it works, or a way that it can work
I'll talk to @tiny oasis about this and see how he feels. That's his playground, but I agree with you, this would be a great thing to roll out as a library.
UITK related question for you! If we did this, and then wanted to jump to UITK at some point, would we be able to update such a library so that in UITK we could keep the same basic look and feel?
well yeah, that's what a public API is for
I'm thinking mainly of the textures for the buttons and windows, etc.
if you design it to be abstract enough, then you can change your internal implementation and keep the same API
so that mods don't need to change anything
or not much, I should say
I'd like that very much!
since with IMGUI you do have to call stuff from OnGUI
and that's not a thing in UITK
so yeah, small adjustments will be needed, but if you design it well enough, not many
the biggest difference is the lifecycle of those two UI libraries
IMGUI basically runs your rendering method (OnGUI) multiple times per frame
with UITK you render things once, and then only change things whenever they need to be changed
That would mean some changes for our mods too then, but these are not bad things to do.
yeah
if you want an example of (almost) the same mod UI in IMGUI and in UITK, you can look at SpaceWarp:
IMGUI: https://github.com/SpaceWarpDev/SpaceWarp/blob/main/SpaceWarp/UI/ModListUI.cs
UITK: https://github.com/jan-bures/SpaceWarpUI/blob/main/Assets/ModList.uxml and https://github.com/SpaceWarpDev/SpaceWarp/blob/uitk-rewrite/SpaceWarp/UI/ModList/ModListController.cs
(though I imagine you wouldn't be using UXML markup packaged in asset bundles but instead using my UitkForKsp2 library's API for creating UI elements)
but that's up to you
you can either make your UI markup in Unity's HTML and CSS equivalents (UXML and USS) in the Unity Editor and then export it into bundles, and add functionality in your C# code, or you can write it all in C# only
the advantage of the first approach is that you get a visual editor in Unity with a live preview of any changes
and your "view" and "controller" are separate layers which arguably is better because of separation of concerns
but of course you can still design your C#-only UI to be the same way
here's an example of the UI Builder in Unity
Cool! That would certainly be nice to be able to use!
@visual bone , how did you create your mod? I mean what was your first step? Cause the folder layout is odd and the csproj is really odd. Did you follow the SpaceWarp template?
You've got duplicate files in several places. toggle_notifications\images, toggle_notifications\assets\images, and Toggle NotificationsProject\assets\images for example.
Those should all be in one place I think
I already fixed that in my PR into his dev branch
Excellent! I'll wait for him to act on your PR, then I'll sync to that.
it's merged already
Ok, then something is weird on my end.
I may have forked it wrong or something?
I'll go back to square one and see if I can un-fork this...
oh...
no it's not on your end
seems like he merged my changes into dev, and then merged his (unfixed) master branch back into dev
undoing all the changes
😅
wait actually no
it was the other way around
well now I'm just extremely confused lmao
I definitely don't want to step on help you've given, so I'll stand back and wait until that gets sorted.
https://github.com/cvusmo/Toggle-Notifications/pull/21 yeah I mean here you can see it was merged, but then I can't find the actual commit anywhere in the history of the dev branch
so something went really wrong
Started with spacewarp template then followed flight plan and then made sure to use the same version of flight plan
Fail. My bad I'm still learning how github works. Feelsbadforbeingabeginner
If you followed the spacewarp template then I don't think there should be things like this <TargetFramework>net472</TargetFramework> in your csproj. That's confusing to me.
That's not what the spacewarp tempate says to do I think, and it's not in FP.
I switched to net472 because shadowdev had said to
seems to me like you may have continued working on your changes without pulling the PR commit into your local repository, and then when you pushed that, there was a conflict?
I've been using GitHub for years and I still screw things up. Don't feel too bad
yeah there's no good reason to do that unless you specifically require an API that isn't available in the .NET Standard 2.0
Honestly don't have a good understanding of push/pull/fetch
Unity and BepInEx both explicitly state you should use .NET Standard 2.0
do not listen to that noob! What does he know? 😉
Can't even make a multi-player mod. Noob
bruh
LOL! We woke the lion!

it is easy. the position system is dumb
the multiplayer part is done. its just the game part thats not.
Yeah, that'll be the easy part, too!
I mean yeah, of course sending data over the network is simple
the hard part is to make it work with the game systems
has anyone actually figured out how the position system works...
Yes. KontrolSystem2 and FP both use it
I never said that. I just gave you my template.
pulls the I-cant-remember-card
will take a look. because every time I update the position the ship explodes.
Also he's right
Lazy orbit uses it to, for that matter. Let's you jump all over the place
Good point, I was just assuming it used it since position was clearly involved. What about looking at the game's TeleportToOrbit method to see how it's done?
well, this is one of the internal methods that handle teleportation
I imagine for smooth movement this is very far away from what you'd need
ye that would take too long. and the problem is the frame of reference.
Here are some examples from FP.
// Get the orbital velocity at a given time in left handed world coordinates. This value will rotate
// due to the inverse rotation tick-to-tick.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3d WorldOrbitalVelocityAtUT(this PatchedConicsOrbit o, double UT) // KS2: OrbitalVelocity // was: SwappedOrbitalVelocityAtUT
{
// return o.getOrbitalVelocityAtUT(UT).xzy
return o.referenceBody.transform.celestialFrame.ToLocalPosition(o.ReferenceFrame, o.GetOrbitalVelocityAtUTZup(UT).SwapYAndZ); // from KS2
}
// Get the body centered inertial position at a given time in left handed world coordinates. This value
// will rotate due to the inverse rotation tick-to-tick.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3d WorldBCIPositionAtUT(this PatchedConicsOrbit o, double UT) // KS2: RelativePosition // was: SwappedRelativePositionAtUT
{
// return o.getRelativePositionAtUT(UT).xzy
return o.referenceBody.transform.celestialFrame.ToLocalPosition(o.ReferenceFrame, o.GetRelativePositionAtUTZup(UT).SwapYAndZ); // From KS2
}
// Get the world space position at a given time in left handed world coordinates. This value
// will rotate due to the inverse rotation tick-to-tick.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3d WorldPositionAtUT(this PatchedConicsOrbit o, double UT) // was: SwappedAbsolutePositionAtUT
{
// return o.referenceBody.Position.localPosition + o.WorldBCIPositionAtUT(UT);
return o.referenceBody.transform.celestialFrame.ToLocalPosition(o.ReferenceFrame, o.referenceBody.Position.localPosition + o.GetRelativePositionAtUTZup(UT).SwapYAndZ); // from KS2
}```
FP has similar methods for Right Handed coordinates (adapted from the latest MJ code)
Here's an example of how to use this with the new KSP2 Position and Velocity.
//returns a new PatchedConicsOrbit object that represents the result of applying a given dV to o at UT
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static PatchedConicsOrbit PerturbedOrbit(this PatchedConicsOrbit o, double UT, Vector3d dV)
{
// return MuUtils.OrbitFromStateVectors(o.WorldPositionAtUT(UT), o.WorldOrbitalVelocityAtUT(UT) + dV, o.referenceBody, UT);
return o.CreateOrbit(o.WorldBCIPositionAtUT(UT), o.WorldOrbitalVelocityAtUT(UT) + dV, UT); // From KS2
// Actual KS2 returns: ReferenceBody.CreateOrbit(RelativePosition(ut), OrbitalVelocity(ut) + dV, ut);
}
// Adapted from KS2
public static PatchedConicsOrbit CreateOrbit(this PatchedConicsOrbit o, Vector3d position, Vector3d velocity, double UT)
{
PatchedConicsOrbit orbit = new(o.referenceBody.universeModel);
// Actual KS2 returns: orbit.UpdateFromStateVectors(new Position(body.SimulationObject.transform.celestialFrame, position), new Velocity(body.SimulationObject.transform.celestialFrame.motionFrame, velocity), body, ut);
orbit.UpdateFromStateVectors(new Position(o.referenceBody.SimulationObject.transform.celestialFrame, position), new Velocity(o.referenceBody.SimulationObject.transform.celestialFrame.motionFrame, velocity), o.referenceBody, UT);
return orbit;
}```
acciedently figured it out
taht allows esc to function properly
and this makes it all wonky
One place where things get dicey is in messing with maneuverPlanSolver. The issue I've run into, which may or may not be a factor for multiplayer, is that the game is doing some ODE solving and simulation with orbits and for some things I need to let the game wait a tick to catch up with itself.
what??
black magic
you're saying that the default value for Solar config is the value of Pause config and vice versa
Wires crossed mutch?
also i figured this out as I was trying to undersatnd why when i changed both of them to disable, it wasnt showing the correct GUI style for the enable buttons
That would be what we in the biz call a clue!
Compared to those who don't mod, everything we do is back magic and wizardry
what's funny is people think i know what im doing and im like "I HAVE NO IDEA. I just wanted to make a mod and they bullied me into it."
I get so amused with the ppl on the main forum who whine that things don't work in the game, and then when you point them to mods that can help say "I don't play with mods". Might as well say, "Sorry, my IQ isn't high enough to realize there are fixes for things that would help me enjoy this more"
I love when people use the word "optimization" like they know wtf that means
i can barely get a GUI to show up and do literally anything
i cant imagine trying to make KSP in its entirety and it actually compile and work
It's a big project with a lot of smart ppl working on it, any one of which can probably code circles around me in their sleep.
You are the mememaster...
See what I meme?
also i prefer GifMaestro
As you wish, your highness...
This is good, but you don't need radio buttons for the enable/disable. Those can be just ordinary toggle buttons. They can switch text to say Enable vs Disable as you press them.
That would put the label on the same line as the toggle button.
oh i switched them back to regular toggle buttons
i realized that the radio buttons were literally the same thing so i removed them with the current version im on
except still using names that say radiobutton for now, til its functional
OK, but what you've got there looks like if you press an Enable button, it will unpress the corresponding Disable, no?
My point is really that you don't need two buttons for this where one will do
so that you get the two options and one can be set and the other gets disabled
its more the visual that im going for with two button approach
since theres really not much to the gui other than turning on and turning off
A given notification is either enabled or it's disabled. it can't be both or neither.
right now, it just stays on.
i was hoping i could said it to a config value and then change the value to true/false
As you add more things to control your GUI will fill up and you'll be glad it's taking less space
also looked into the harmonyunpatch
which so far ive not figured out a way to deactivate the notification so that it can actually work again
thats weird
basically i havent figured out how to toggle notifications

That's not entirely true. You can toggle them, you just need the player to restart the game for some settings to take effect.
What you may not have yet is a dynamic toggle that works while the game is running
no idea how to even do that
which is what ill need for this to work and function properly i guess
SpaceWarp is like this for mod enable/disable. There are some things that may simply be like this due to fundamental things we can't control (or are not smart enough to control yet)
I would connect the toggles to your mod's config settings, then read the settings on launch and apply them. If there are new settings (which is fine), then save them and alert the user they need to restart the game for those settings to take effect.
so getting this to function how i want is a challenge
thats what i thought i did
unless this has nothing to do with it
which would cause issues
Take it one step at a time. Perhaps with 0.2.x there's a restart required for some (perhaps all) settings, but still it's a useful mod. Then planned for 0.3.x or 0.4.x or what ever is dynamic toggling.
that was my exact idea
0.2.2 add gui with nice buttons
something pretty that is functionalish
If you don't mind my asking, why are you posting screen shots of of code rather than posting the code as text?
its fast to take a screenshot and i dont know a quick way to insert code
is there a quiock way to insert code?
Yes, you copy it... and then you paste it!
[HarmonyPatch(typeof(MessageCenter))]
public static class MessageCenterPublishPatch
{
[HarmonyPrefix]
[HarmonyPatch(nameof(MessageCenter.Publish), typeof(System.Type), typeof(MessageCenterMessage))]
public static bool Prefix(System.Type type, MessageCenterMessage message)
{
if (type == typeof(PauseStateChangedMessage))
{
PauseStateChangedMessage pauseMessage = (PauseStateChangedMessage)message;
if (pauseMessage.Paused)
{
Logger.LogInfo("Game is paused");
return true;
}
else
{
Logger.LogInfo("Game is unpaused");
return true;
}
}
return true;
}
}
but it looks ugly?
The trick is getting it to format nicely, which is actually very easy
```cs
your code
```
Like this. Start a new line and put 3 ` characters down followed by a cs
What he said
with "cs" being the language you are using (cs = C Sharp = C#)
Listen to quickdrawmgraw
'''cs [HarmonyPatch(typeof(MessageCenter))]
public static class MessageCenterPublishPatch
{
[HarmonyPrefix]
[HarmonyPatch(nameof(MessageCenter.Publish), typeof(System.Type), typeof(MessageCenterMessage))]
public static bool Prefix(System.Type type, MessageCenterMessage message)
{
if (type == typeof(PauseStateChangedMessage))
{
PauseStateChangedMessage pauseMessage = (PauseStateChangedMessage)message;
if (pauseMessage.Paused)
{
Logger.LogInfo("Game is paused");
return true;
}
else
{
Logger.LogInfo("Game is unpaused");
return true;
}
}
return true;
}
} cs'''
ohhh
Close!
it's backticks, not apostrophes
and the code needs to start on a new line after the "cs"
(i think)
and don't need a "cs" at the end
public static class MessageCenterPublishPatch
{
[HarmonyPrefix]
[HarmonyPatch(nameof(MessageCenter.Publish), typeof(System.Type), typeof(MessageCenterMessage))]
public static bool Prefix(System.Type type, MessageCenterMessage message)
{
if (type == typeof(PauseStateChangedMessage))
{
PauseStateChangedMessage pauseMessage = (PauseStateChangedMessage)message;
if (pauseMessage.Paused)
{
Logger.LogInfo("Game is paused");
return true;
}
else
{
Logger.LogInfo("Game is unpaused");
return true;
}
}
return true;
}
} c#```
Also don't need the cs prior to the backticks at the end
Just naked backticks
thast good to know
I mean who doesn't like naked backticks?
```cs
[HarmonyPatch(typeof(MessageCenter))]
public static class MessageCenterPublishPatch
{
[HarmonyPrefix]
[HarmonyPatch(nameof(MessageCenter.Publish), typeof(System.Type), typeof(MessageCenterMessage))]
public static bool Prefix(System.Type type, MessageCenterMessage message)
{
if (type == typeof(PauseStateChangedMessage))
{
PauseStateChangedMessage pauseMessage = (PauseStateChangedMessage)message;
if (pauseMessage.Paused)
{
Logger.LogInfo("Game is paused");
return true;
}
else
{
Logger.LogInfo("Game is unpaused");
return true;
}
}
return true;
}
}
```
this is how it should be
Certainly discord likes them
so that you get the proper syntax highlighting
mind blown
Yep, great for referring to variables or methods in a comment
it's basically just markdown
Want to inject some flavor into your everyday text chat? You're in luck! Discord uses Markdown, a simple plain text formatting system that'll help you make your sentences stand out. Here's how to d...
the same thing you can use for README formatting on GitHub, for example
though it's much more limited here
//SolarToggleConfig = Config.Bind("Notification Settings", "Solar Config", true, "Solar configuration value");
//PauseToggleConfig = Config.Bind("Notification Settings", "Pause Toggle State Config", true, "Game Pause Toggle State configuration value");
TNconfig = Config.Bind("Notification Settings", "Toggle Notifications", defaultValue, "Toggle Notifications is a mod that allows you to enable or disable notifications");
defaultValue = TNconfig.Value;
TNconfig.Value = true;
// Create the initialNotificationStates dictionary and populate it
Dictionary<NotificationType, bool> initialNotificationStates = new Dictionary<NotificationType, bool>()
{
{ NotificationType.GamePauseToggledMessage, PauseToggleConfig.Value },
{ NotificationType.PauseStateChangedMessageToggle, PauseToggleConfig.Value },
{ NotificationType.SolarPanelsIneffectiveMessage, SolarToggleConfig.Value }
};
notificationToggle = new NotificationToggle(this, initialNotificationStates);```
One gotcha is that discord has a limit on how much text you can paste into a single post. I will sometimes unindent my code block before pasting it, then re-indent it in vs. Or I'll rip out comments or whatever to get it to fit better
I just learned that lol
Learned it the same way I did then!
// configuration
//SolarToggleConfig = Config.Bind("Notification Settings", "Solar Config", true, "Solar configuration value");
//PauseToggleConfig = Config.Bind("Notification Settings", "Pause Toggle State Config", true, "Game Pause Toggle State configuration value");
TNconfig = Config.Bind("Notification Settings", "Toggle Notifications", defaultValue, "Toggle Notifications is a mod that allows you to enable or disable notifications");
defaultValue = TNconfig.Value;
TNconfig.Value = true;
// Create the initialNotificationStates dictionary and populate it
Dictionary<NotificationType, bool> initialNotificationStates = new Dictionary<NotificationType, bool>()
{
{ NotificationType.GamePauseToggledMessage, PauseToggleConfig.Value },
{ NotificationType.PauseStateChangedMessageToggle, PauseToggleConfig.Value },
{ NotificationType.SolarPanelsIneffectiveMessage, SolarToggleConfig.Value }
};
notificationToggle = new NotificationToggle(this, initialNotificationStates);```
public ConfigEntry<bool> TNconfig;
protected bool defaultValue;
public ConfigEntry<bool> SolarToggleConfig { get; private set; }
public ConfigEntry<bool> PauseToggleConfig { get; private set; }```
yeah I generally unindent any code I'm posting here, because it just looks better when it starts at the start of the block
ohh
There's something amiss with how you're putting that in. The syntax highlighting is not coming through
Agree!
is your first line this?
```cs
No space between the backticks and the cs
and three backticks, no more and no less
It's like "one ping only, Vasily" if you catch my reference
cs test
I'm guessing that's a goof. The 'cs' should not appear
Not Witcraft, but it does involve the dark arts...
cspublic override void OnInitialized()
{
// initialize
base.OnInitialized();
TNBaseSettings.Init(SettingsPath);
Instance = this;
Logger = base.Logger;
Logger.LogInfo("Loaded");
MainUI = new ToggleNotificationsUI(this, isGUIVisible);
Debug.Log("MainUI instantiated");
game = GameManager.Instance.Game;
// Register Flight AppBar button
Appbar.RegisterAppButton(
"Toggle Notifications",
ToolbarFlightButtonID,
AssetManager.GetAsset<Texture2D>($"{this.SpaceWarpMetadata.ModID}/images/icon.png"),
isOpen =>
{
ToggleButton(isOpen, isOpen);
Debug.Log($"Initial isWindowOpen value: {interfaceEnabled}");
}
);
// configuration
TNconfig = Config.Bind("Notification Settings", "Toggle Notifications", defaultValue, "Toggle Notifications is a mod that allows you to enable or disable notifications");
defaultValue = TNconfig.Value;
TNconfig.Value = true;
// Create the initialNotificationStates dictionary and populate it
Dictionary<NotificationType, bool> initialNotificationStates = new Dictionary<NotificationType, bool>()
{
{ NotificationType.GamePauseToggledMessage, PauseToggleConfig.Value },
{ NotificationType.PauseStateChangedMessageToggle, PauseToggleConfig.Value },
{ NotificationType.SolarPanelsIneffectiveMessage, SolarToggleConfig.Value }
};
notificationToggle = new NotificationToggle(this, initialNotificationStates);
AssistantToTheAssistantPatchManager.ApplyPatches(notificationToggle);
}```cs```
OH
{
// initialize
base.OnInitialized();
TNBaseSettings.Init(SettingsPath);
Instance = this;
Logger = base.Logger;
Logger.LogInfo("Loaded");
MainUI = new ToggleNotificationsUI(this, isGUIVisible);
Debug.Log("MainUI instantiated");
game = GameManager.Instance.Game;
// Register Flight AppBar button
Appbar.RegisterAppButton(
"Toggle Notifications",
ToolbarFlightButtonID,
AssetManager.GetAsset<Texture2D>($"{this.SpaceWarpMetadata.ModID}/images/icon.png"),
isOpen =>
{
ToggleButton(isOpen, isOpen);
Debug.Log($"Initial isWindowOpen value: {interfaceEnabled}");
}
);
// configuration
TNconfig = Config.Bind("Notification Settings", "Toggle Notifications", defaultValue, "Toggle Notifications is a mod that allows you to enable or disable notifications");
defaultValue = TNconfig.Value;
TNconfig.Value = true;
// Create the initialNotificationStates dictionary and populate it
Dictionary<NotificationType, bool> initialNotificationStates = new Dictionary<NotificationType, bool>()
{
{ NotificationType.GamePauseToggledMessage, PauseToggleConfig.Value },
{ NotificationType.PauseStateChangedMessageToggle, PauseToggleConfig.Value },
{ NotificationType.SolarPanelsIneffectiveMessage, SolarToggleConfig.Value }
};
notificationToggle = new NotificationToggle(this, initialNotificationStates);
AssistantToTheAssistantPatchManager.ApplyPatches(notificationToggle);
}```
son of a
Munix, how to you escape the backticks so they come through in your example?
it looks to me like you aren't putting the "cs" right next to the backticks
{
// initialize
base.OnInitialized();
TNBaseSettings.Init(SettingsPath);
Instance = this;
Logger = base.Logger;
Logger.LogInfo("Loaded");
MainUI = new ToggleNotificationsUI(this, isGUIVisible);
Debug.Log("MainUI instantiated");
game = GameManager.Instance.Game;
// Register Flight AppBar button
Appbar.RegisterAppButton(
"Toggle Notifications",
ToolbarFlightButtonID,
AssetManager.GetAsset<Texture2D>($"{this.SpaceWarpMetadata.ModID}/images/icon.png"),
isOpen =>
{
ToggleButton(isOpen, isOpen);
Debug.Log($"Initial isWindowOpen value: {interfaceEnabled}");
}
);
// configuration
TNconfig = Config.Bind("Notification Settings", "Toggle Notifications", defaultValue, "Toggle Notifications is a mod that allows you to enable or disable notifications");
defaultValue = TNconfig.Value;
TNconfig.Value = true;
// Create the initialNotificationStates dictionary and populate it
Dictionary<NotificationType, bool> initialNotificationStates = new Dictionary<NotificationType, bool>()
{
{ NotificationType.GamePauseToggledMessage, PauseToggleConfig.Value },
{ NotificationType.PauseStateChangedMessageToggle, PauseToggleConfig.Value },
{ NotificationType.SolarPanelsIneffectiveMessage, SolarToggleConfig.Value }
};
notificationToggle = new NotificationToggle(this, initialNotificationStates);
AssistantToTheAssistantPatchManager.ApplyPatches(notificationToggle);
}```
with a backslash
works for any of the formatting characters like *hello*
public override void OnInitialized()
{
// initialize
base.OnInitialized();
TNBaseSettings.Init(SettingsPath);
Instance = this;
Logger = base.Logger;
Logger.LogInfo("Loaded");
MainUI = new ToggleNotificationsUI(this, isGUIVisible);
Debug.Log("MainUI instantiated");
game = GameManager.Instance.Game;
// Register Flight AppBar button
Appbar.RegisterAppButton(
"Toggle Notifications",
ToolbarFlightButtonID,
AssetManager.GetAsset<Texture2D>($"{this.SpaceWarpMetadata.ModID}/images/icon.png"),
isOpen =>
{
ToggleButton(isOpen, isOpen);
Debug.Log($"Initial isWindowOpen value: {interfaceEnabled}");
}
);
// configuration
TNconfig = Config.Bind("Notification Settings", "Toggle Notifications", defaultValue, "Toggle Notifications is a mod that allows you to enable or disable notifications");
defaultValue = TNconfig.Value;
TNconfig.Value = true;
// Create the initialNotificationStates dictionary and populate it
Dictionary<NotificationType, bool> initialNotificationStates = new Dictionary<NotificationType, bool>()
{
{ NotificationType.GamePauseToggledMessage, PauseToggleConfig.Value },
{ NotificationType.PauseStateChangedMessageToggle, PauseToggleConfig.Value },
{ NotificationType.SolarPanelsIneffectiveMessage, SolarToggleConfig.Value }
};
notificationToggle = new NotificationToggle(this, initialNotificationStates);
AssistantToTheAssistantPatchManager.ApplyPatches(notificationToggle);
}```
c# helloworld
So that was a
```cs
your code bock
```
string x = "y"
namespace ToggleNotifications
{
public enum NotificationType
{
SolarPanelsIneffectiveMessage,
VesselThrottleLockedDueToTimewarpingMessage,
CannotPlaceManeuverNodeWhileOutOfFuelMessage,
GamePauseToggledMessage,
PauseStateChangedMessageToggle,
None
}
}
HAHA
nice
Yay!
Now you're gonna be posting like a pro!
do i need to give these initial values?
// configuration
TNconfig = Config.Bind("Notification Settings", "Toggle Notifications", defaultValue, "Toggle Notifications is a mod that allows you to enable or disable notifications");
defaultValue = TNconfig.Value;
TNconfig.Value = true;
// Create the initialNotificationStates dictionary and populate it
Dictionary<NotificationType, bool> initialNotificationStates = new Dictionary<NotificationType, bool>()
{
{ NotificationType.GamePauseToggledMessage, PauseToggleConfig.Value },
{ NotificationType.PauseStateChangedMessageToggle, PauseToggleConfig.Value },
{ NotificationType.SolarPanelsIneffectiveMessage, SolarToggleConfig.Value }
};
notificationToggle = new NotificationToggle(this, initialNotificationStates);
so that works?
I think they get defaults if you don't
I don't really understand the first few lines here
why do you first use defaultValue and then assign to it
I suspect you don't need that dictionary. It looks like something needed for radio buttons maybe
hm
me trying to remember why i coded it this way and realizing that once it worked i brain dumped the why
really the default value for a bool toggle should just be "true" or "false"
My guess is that you lifted that from FP
it's the value that the config option will have when you first launch the game with the mod installed
so the basic thing im trying to do
after that it's never used again
is just have three separate values for three separate config values
that dont hold the same value, theyre completely separate
FP has a bunch of radio buttons and I use a dictionary to help make them behave, but I don't think you need any of that
theres a lot from fp ill be removing, but keeping a lot in the code in case i need it for now
//config
public ConfigEntry<bool> tnConfig { get; private set; }
public ConfigEntry<bool> SolarToggleConfig { get; private set; }
public ConfigEntry<bool> PauseToggleConfig { get; private set; }
is that how i should create them in the beginning of the plugin?
well depends on if they need to be public and properties
unless you want a different mod (or a different assembly within your mod) to be able to access them, basically nothing you write needs to be public
good to know
and if it's not public, there's not really any need to make them properties
basically:
- public - can be accessed by anyone from anywhere
- internal - can be accessed from anywhere inside your project
- protected - can be accessed in the class where it's defined and in all classes that extend it
- protected internal - can be accessed from anywhere inside your project and in all classes that extend the class it's defined in
- private - can be accessed only in the class where it's defined
- private protected - can be accessed only in the class where it's defined and in your project's classes that extend the class it's defined in
##- internal - can be accessed from anywhere inside your project
thats huge
##- internal - can be accessed from anywhere inside your project## ?
nope messed that up
so basically everything thats public can turn into internal
the code clean up is planned for 0.2.4
0.2.2 = gui functionjing and such
the server had the extra formatting features like lists and headings enabled for some time but then Discord disabled it again
no idea why
weird
this is a nice summary
(quoted a wrong message)
that is nice
yeah, you need to roll back the changes in your .csproj file
that contains some "public" text
like "publicize"
so I imagine you also changed that accidentally
all i did was do crtl + h "public" =>> "internal"
now the entire csproj is jacked up
oh yeah and from the first error: you also changed the "BepInEx.AssemblyPublicizer.MSBuild" package to "BepInEx.Assemblyinternalizer.MSBuild" lol
fml
how do i do that?
oh but wait
that will roll back all changes in all files it seems
dumb VS
ok then just switch into folder view
and find the .csproj file in there and do the same thing as above
one thing is, you will want to keep your plugin class public
yeah i figured that
and some lifecycle methods also need to be public if they're overrides
cause the bepinex needs access to it
like OnInitialized
yup those were things i figurd needed to stay public
now im doing it the methodical way
going file by file and changing them to internal
think i made it change correctly
it's not angry anymore
so thats good
i lied
fuck
Off hand, I'd say be careful with global search and replace like that. At the least you'd probably want to make it case sensitive and whole word, but I sounds like you've recovered from the initial damage.
This looks like it's working much better. Personally, I'd still prefer a single toggle per effect - but it's your baby and as long as it works I'll be delighted to use it!
You've done a great job on the UI!
The secret is I'm going to rework the buttons to be used for four different notifications
Love your icon, btw.
You can make it bigger pretty easily.
Via photoshop or just with coding?
I think it may scale to the size of the rect it's given, provided it's bigger than the rect.
Cause I know exsctly how to make it bigger in photoshop lol
I also have plans for advanced and simple
So eventually the gear is going to allow you to switch to simple mode
Slim. Sleek. But that's down the road
This is part of why in FP I had different sized icons. I ultimately didn't use a lot of them, but I wanted the native images to be at least close to what I was planning to use them for
Ah makes sense
Before 0.2.2 release I'll be slimming the mod down a bit and remove unnecessary pngs etc
That's a good thing to do.
Yup
