#Toggle Notifications devlog

1 messages · Page 2 of 1

visual bone
#

not to brag but i made a few scripts for arma 3 and used kOS

#

lol

timid quail
#

heh

visual bone
#

humor

#

im new to it so a lot i dont know and i learn by doing

#

its also fun to me

timid quail
#

I loved making Starship flight test KOS scripts

visual bone
#

figuring out how and why things work

#

it was explosive to do so

#

i liked doing it on mun

timid quail
#

SN5 hop was a challenge, dealing with the offset thrust

visual bone
#

where you do a suicide burn to land on mun

#

super fun

timid quail
#

at least I found some practical use for my linear algebra uni classes

visual bone
#

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

visual bone
wanton lava
#

thats just a spacewarp error, you are safe to ignore

timid quail
#

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

visual bone
#

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

visual bone
#

so now i have zero GUI lol

worn token
#

f2 maybe?

#

or did you break the GUI that bad 💀

visual bone
#

i now have toggle buttons

#

well, at least i coded it whether it loads and works, NFI

visual bone
junior iris
visual bone
#

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

junior iris
#

hmmm

#

i have a good tutorial on that a sec

#

will take a bit of programming tho

visual bone
#

heck yeah

#

the thing im getting confused on

#

with 90% of this, is which api i should use, spacewarp, bepinex, unity

junior iris
#

note that he's doing this inside of unity (which u can also do)

visual bone
#

like where the heck does unity gui come from

junior iris
#

but this can all be done only via coding too

visual bone
#

thats good

#

the goal

#

is to create a gui that has tabs

#

and each tab correlates to various notifications

junior iris
#

btw if you want, you can create the UI in Unity and then import it in game

visual bone
#

what??

#

so i can run unity

junior iris
#

@timid quail knows a bit more about that than i do

visual bone
#

hm

junior iris
#

importing IMGUI

visual bone
#

thats cool

#

for now i wanna use this

timid quail
junior iris
#

yes, you create the prefab and then instantiate it

timid quail
#

For IMGUI?

#

Never heard of that

junior iris
#

just pack it in a asset bundle

timid quail
#

Doesn't it have only a C# API?

junior iris
#

i mean yeah thats how most games build their UI xD

#

Wait, the default unity ui is IMGUI right?

timid quail
#

No, not really, IMGUI is a debugging tool

junior iris
#

Ok im dumb then

timid quail
#

No, the default is Unity UI

#

Which you build with canvases and game objects

junior iris
#

but it still applies, you can build the UI on unity and then import it in game

timid quail
#

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

visual bone
#

hm

junior iris
#

yeah but if you build a more complex ui i think its better to build it in unity

junior iris
visual bone
#

where do i find UITK?

junior iris
#

#1085537097714245662

visual bone
#

ah

timid quail
#

But it's not really production-ready

visual bone
#

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

timid quail
#

they just finished making a tabbed UI

visual bone
#

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

timid quail
#

and the rest is just the game code itself

visual bone
#

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

timid quail
#

pretty much

visual bone
#

im over here using plungers to build a house

timid quail
timid quail
# visual bone

is this commented out stuff what you were having issues with?

visual bone
#

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

visual bone
#

on the right trakc now

visual bone
#

figuring out what async does and using it

worn token
#

That yandere simulator type copy paste tho aaaa munleyix

visual bone
#

copy pasta, then i salt bae it

visual bone
#

ah... the satisfaction of organized code thats repetitive. also i have a horrible memory so i keep forgetting what ive named things

visual bone
#

hookedonC#worked for me

visual bone
#

Update: all i need to do is get togglenotificationsui.cs and selection.cs working together.

visual bone
#

I think i've overcomplicated this @opal lagoon

opal lagoon
visual bone
#

It's almost ready

opal lagoon
#

I NEED this mod! I’m really getting sick of useless notifications popping up on my screen…

visual bone
#

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

visual bone
#

ALMOST ready for a test

#

jus tneed to make converttomessagecentermessage an actual thing

visual bone
visual bone
#

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 🙏

opal lagoon
#

Why are you trying to make a tabbed GUI for your mod?

visual bone
#

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

opal lagoon
#

What's the role of the mod config variables?

visual bone
#

That's what turns the notificationevents on and off via harmony patch

opal lagoon
#

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!

visual bone
#

Github is updated with what I'm working on

visual bone
#

Also I want to learn how to code the gui and make it work

opal lagoon
#

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

visual bone
#

True

#

I have pages for each notification mainly for curiosity

#

The end result will probably be 2-3 tabs Max

opal lagoon
#

How much info do you have on each page?

visual bone
#

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

opal lagoon
#

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

visual bone
#

No hot key

opal lagoon
#

I've never had any luck getting the debugger to stop inside OnInitilzed as it's running so damn early

visual bone
#

Hmm

opal lagoon
#

So, litter the thing with Logger prints!

visual bone
#

I'm sure it's something little

#

🤣🤣

#

I'm just going one error at a time

opal lagoon
#

Seriously, you may be able to isolate the offending line that way

visual bone
#

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

visual bone
#

Toggle Notifications v0.3.0 Progress

#

Toggle Notifications v0.3.0 devblog

opal lagoon
visual bone
#

I got a shiny button. I got a shiny button!

visual bone
visual bone
#

now its just a matter of getting it setup and probably going to have to create some new GUI elements

visual bone
#

what controls the Allow plugin to run on every frame... Update?

visual bone
visual bone
#

this all makes sense now

visual bone
#

oh! we have a green light

no GUI yet. but progress

visual bone
visual bone
#

@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

visual bone
#

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

visual bone
visual bone
visual bone
#

finally

opal lagoon
#

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

opal lagoon
# visual bone finally

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.

visual bone
#

but harmonypatch could be completely wrong and i may need to scrub it and use a different method to disable notifications

opal lagoon
#

Can it prevent notificiations?

visual bone
#

not sure yet

#

theoretically it is working

#

but its not

#

so for example when i click pause

#

it still dispplays the gui

opal lagoon
#

Simple. Have a test sat with solar panels and watch as the mofo flys around into the shadow of Kerbin

visual bone
opal lagoon
#

I'd love to never see that particular notification again

visual bone
#

no need to leave launchpad, i just speed up time

opal lagoon
#

Sure, just simulating an extremely low kerbin orbit...

visual bone
#

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

opal lagoon
#

Why have you got it disabled?

visual bone
#

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

opal lagoon
#

Interesting.

visual bone
#

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

opal lagoon
#

Start a new mod using the spaceward template

visual bone
#

which means my settingsfile and configfile are borked

#

so how do i get all of this that ive worked on into a fresh mod?

opal lagoon
#

Then bring the harmony patching crap int the new mod after you're user it doesn't get set this way

visual bone
#

ah

opal lagoon
#

I'd use copy/paste, but that's up to you. retyping it all works too

visual bone
#

use a fresh mod to see if it does anything

opal lagoon
#

😛

visual bone
#

not retyping

#

lol

opal lagoon
#

Seriously. Start a new one called TestMod or whatever

visual bone
#

LOL

opal lagoon
#

Get it up as a shell with a stupid simple GUI that does squat

visual bone
#

i literally named it that

opal lagoon
#

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

visual bone
#

that makes sense

opal lagoon
#

If this stupid setting goes to disabled again, you'll have found what did it

visual bone
#

figures out where it broke

timid quail
#

can I see your current main plugin class?

visual bone
#

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

timid quail
#

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

visual bone
#

thats so weird

#

but makes sense

#

line reference to it?

timid quail
#

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

visual bone
#

oh

#

alright time to figure out how and why its running an OnDisable method

timid quail
#

yeah, the component is the only one that is disabled by BepInEx for some reason

visual bone
#

LUL

timid quail
#

and when I do enable it manually, I get exception spam

#

(though this is from the 0.2 version from CKAN)

visual bone
#

true

#

thats pretty wild

timid quail
#

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

visual bone
#

will do

visual bone
#

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

timid quail
visual bone
timid quail
#

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

visual bone
#

thank you munix

timid quail
#

glad to help

visual bone
timid quail
#

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?

visual bone
#

i forgot i changed from v 0.2.0 to v 0.3.0 lol

#

also

#

brain farted and just made another repo

visual bone
#

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?

GitHub

Contribute to cvusmo/Toggle-Notifications development by creating an account on GitHub.

visual bone
#

working on GUI stuff

wanton lava
#

that icon looks good

visual bone
#

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

visual bone
#

FINALLY!

we have a window

#

lots of little mistakes

#

but finally getting this thing to work

#

first mod is the hardest right? LUL

wanton lava
#

I feel like you have gone excessively complex for what it needs lol.

visual bone
#

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

wanton lava
#

whats on line 220

visual bone
#

notificationToggle.SetNotificationState(notificationType, enableNotification);

wanton lava
#

notificationToggle is lowercase?

#

where is that set?

visual bone
#

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

wanton lava
visual bone
#

thats what sets the value

wanton lava
#

not that

visual bone
#

hm

wanton lava
#

wheres it getting defined

visual bone
#

that is where its being defined?

wanton lava
#

like string x = "y"

visual bone
#

its within the class and the definition im pretty sure is the notificationStates[notificationType] = currentState;

#

right? am i understanding that correctly?

wanton lava
#

no lol

#

inside of ToggleNotificationPlugin.cs notificationToggle where is it created in that file

visual bone
#

son of a

wanton lava
#

what?

#

do you have this on github

visual bone
#

not this version but ill push it up

wanton lava
#

please do

visual bone
#

i just spent a good few hours simplifying it

#

give me just a sec

wanton lava
#

I have 4 mins until my next meeting.

visual bone
#

no worries

#

whenever you get a chance to look i appreciate it. ill have it up in devbranch shortly

visual bone
#

• 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));

visual bone
visual bone
visual bone
visual bone
#

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

visual bone
#

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.

visual bone
#

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

visual bone
#

Will continue later today with getting harmony patches working correctly.

worn token
#

You've not set what it should patch according to the error ^

visual bone
worn token
#

Yep

visual bone
# worn token Yep

thank you for mentioning that. working on the patches now to get them functional

visual bone
#

currentlyu what im debugging

visual bone
#

Toggle Notifications v0.2.2 devblog

visual bone
#

@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.

opal lagoon
visual bone
#

lol

#

i like the off / on button idea

opal lagoon
#

LOL!

visual bone
#

still haven't figured out how to get ONGui to work properly

opal lagoon
#

Well, you’ve got a look to shoot for then!

visual bone
#

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

opal lagoon
#

Debug logging FTW!

visual bone
#

thanks for all the help so far you're a legend!

opal lagoon
#

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!

visual bone
#

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

opal lagoon
#

Practice! Perseverance! And Patience!

#

Or is the third p Personality?

visual bone
#

LUL

visual bone
#

well, this is the new bug. trying to figure out why this happens. but thats for later today

visual bone
#

This didn't patch anything unfortunately. I had to use other classes including notificationevents to disable game pause and solar

wanton lava
#

was working for me

visual bone
timid quail
#

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;
}
wanton lava
#

I don't mean to be rude but 70% of the code in this mod seems unnecessary.

timid quail
#

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));

visual bone
visual bone
#

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

worn token
#

rm on windows klueless

timid quail
#

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 husK

#

Will be fixed in the next version of the template which I already have finished and is just waiting for SpaceWarp 1.2 release

opal lagoon
timid quail
# opal lagoon 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

opal lagoon
#

What's new in 1.2? I assume this is not bringing UITK?

timid quail
#

well UITK is a separate mod/library, which anyone can use already (though it's far from perfect)

wanton lava
#

I like it.

visual bone
#

hmm

timid quail
# opal lagoon What's new in 1.2? I assume this is not bringing UITK?

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

GitHub

A C# modding API for KSP2 built off of BepInEx. Contribute to SpaceWarpDev/SpaceWarp development by creating an account on GitHub.

#

those are the major changes

opal lagoon
#

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.

timid quail
#

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

visual bone
#

@opal lagoon how do any of your mods work for GUI? im getting these kinds of errors about the GUISkin

timid quail
#

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?

timid quail
#

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?

visual bone
timid quail
#

well that's weird

visual bone
#

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

timid quail
#

at what point does the exception occur?

visual bone
#

so on the appbar i get my icon, but for GUI i get nothing

timid quail
#

is it after the game is fully loaded?

visual bone
#

yeah fully loaded sitting on launchpad chillin

timid quail
#

or during or before?

visual bone
#

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

visual bone
timid quail
#

the "assets" folder shouldn't be a part of the path

visual bone
#

patch works

timid quail
#

for example this is how I register my app bar button

visual bone
#

no it shouldn't but whether i set the path as togglenotifications/images/.... or assets/images/ it still laods the icon.png

timid quail
#

oh now it makes sense

#

you're not using that code at all

visual bone
#

i am

timid quail
visual bone
#

now you've lost me

timid quail
#

you don't use the AssetsLoader class

visual bone
#

son of a

timid quail
#

so now it makes sense why the icon loads

visual bone
#

that makes sense because ive had to slowly make sure things were being used correctly and initalized properly

timid quail
#

because you don't have the "assets" part in it

visual bone
#

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?

timid quail
#

what?

#

no, it's a static class

timid quail
#

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

visual bone
#

so assetsloader isnt even working so i can remove it compeltely from the plugin

#

now to learn how spacewarps assetmanager works

timid quail
#

I mean it's exactly the same, just without the extra debug logs

visual bone
timid quail
#

yeah I mean the KerbonautManagerWindow.IsOpen property is pretty much the exact same thing as your isWindowOpen

visual bone
#

where is kerbonautmanagerwindow from?

timid quail
#

that's just my class aggregating all the UI code

visual bone
#

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

timid quail
#

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

visual bone
#

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

wanton lava
#

if your going through all this effort to use custom imgui components it would be faster to swap to UITK.

visual bone
#

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

timid quail
#

what

#

how is that different from FlightView

visual bone
#

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

timid quail
#

is that only with launch clamps or something?

visual bone
#

nope but now i wanna test and figure out when the game changes the state on the launchpad

#

so currently untested

timid quail
#

well I can't seem to get the Launchpad state when I'm on the launchpad

#

it says FlightView

visual bone
#

dafuq

timid quail
visual bone
#

well that didnt work

#

so iw as 100% wrong

#

but i thougth i figured it out

visual bone
#

smol progress. we have a window finally.

#

but the ongui is being called nonstop and is on an infinite loop.

timid quail
#

yeah that's how it works

#

it gets called multiple times per frame

visual bone
#

oh so because im logging it its just doing what its supposed to do

#

ah

timid quail
#

yeah

visual bone
#

now i gotta figure out how to make the window have buttons and stuff

#

lol

timid quail
#

mind pushing your latest changes again?

#

sorry I haven't had the time to look at it until now

visual bone
#

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

timid quail
#

I see that in your master branch (aka 2.0 I guess) you have the correct path in it

visual bone
#

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

timid quail
#

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

visual bone
#

what do you mean by that?

#

like how i structure my code?

timid quail
#

for example keeping class, method and property names in PascalCase, local variables in camelCase, private fields in _underscoreCamelCase etc

visual bone
#

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

timid quail
#

where is that screenshot even from?

visual bone
#

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

visual bone
timid quail
#

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 😀

timid quail
#

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

visual bone
#

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

visual bone
#

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

timid quail
#

awesome 😆

visual bone
visual bone
#

nailed it... lol

wanton lava
#

lol

visual bone
#

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

opal lagoon
# visual bone nailed it... lol

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

timid quail
#

this is how I handle keeping my close button in the top right corner:

worn token
#

big brain

visual bone
#

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?

visual bone
visual bone
#

holy crap thats cool. BeginArea to create an area within the window

visual bone
#

learning has occurred.

Now to tweak it to make it look better

visual bone
visual bone
#

well, now i need to figure out how to get the in game menu to work again because yeah

visual bone
visual bone
#

@radiant arrow or @tiny oasis any idea where I can find the pause button image that they use in the game?

visual bone
visual bone
visual bone
#

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.

opal lagoon
#

I can't promis I'll be able to solve it, but if you like I'll be happy to take a look.

visual bone
#

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

opal lagoon
#

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

visual bone
#

lol

#

good luck with the master its old

#

0.2.1 and 0.2.2 are very different

timid quail
opal lagoon
#

Ahh... Ok, I'll try to get onto the dev branch then so this can be useful.

timid quail
#

that way you could all avoid duplicating files and classes

visual bone
visual bone
opal lagoon
#

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?

timid quail
#

well yeah, that's what a public API is for

opal lagoon
#

I'm thinking mainly of the textures for the buttons and windows, etc.

timid quail
#

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

opal lagoon
#

I'd like that very much!

timid quail
#

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

opal lagoon
#

That would mean some changes for our mods too then, but these are not bad things to do.

timid quail
#

yeah

#

(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

opal lagoon
#

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

timid quail
#

I already fixed that in my PR into his dev branch

opal lagoon
#

Excellent! I'll wait for him to act on your PR, then I'll sync to that.

timid quail
#

it's merged already

opal lagoon
#

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...

timid quail
#

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

#

😅

opal lagoon
#

LO!

#

Yikes...

timid quail
#

wait actually no

#

it was the other way around

#

well now I'm just extremely confused lmao

opal lagoon
#

I definitely don't want to step on help you've given, so I'll stand back and wait until that gets sorted.

timid quail
#

so something went really wrong

visual bone
visual bone
opal lagoon
#

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.

visual bone
#

I switched to net472 because shadowdev had said to

timid quail
#

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?

opal lagoon
#

I've been using GitHub for years and I still screw things up. Don't feel too bad

timid quail
#

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

visual bone
timid quail
#

Unity and BepInEx both explicitly state you should use .NET Standard 2.0

opal lagoon
wanton lava
opal lagoon
#

LOL! We woke the lion!

timid quail
wanton lava
#

it is easy. the position system is dumb

#

the multiplayer part is done. its just the game part thats not.

opal lagoon
timid quail
#

I mean yeah, of course sending data over the network is simple

#

the hard part is to make it work with the game systems

wanton lava
#

has anyone actually figured out how the position system works...

opal lagoon
wanton lava
visual bone
wanton lava
visual bone
#

Also he's right

opal lagoon
#

Lazy orbit uses it to, for that matter. Let's you jump all over the place

timid quail
#

well, not really (at least not directly)

#

it just uses the game's Lua engine

opal lagoon
#

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?

timid quail
#

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

wanton lava
opal lagoon
#

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;
        }```
visual bone
#

acciedently figured it out

#

taht allows esc to function properly

#

and this makes it all wonky

opal lagoon
#

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.

timid quail
visual bone
timid quail
#

you're saying that the default value for Solar config is the value of Pause config and vice versa

visual bone
#

oh

#

LUL

#

thats not what i was trying to do

opal lagoon
#

Wires crossed mutch?

visual bone
#

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

opal lagoon
opal lagoon
#

Compared to those who don't mod, everything we do is back magic and wizardry

visual bone
#

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."

opal lagoon
#

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"

visual bone
#

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

opal lagoon
#

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.

visual bone
#

thats my intelligence level when it comes to coding

opal lagoon
#

You are the mememaster...

opal lagoon
#

See what I meme?

visual bone
#

also i prefer GifMaestro

opal lagoon
#

As you wish, your highness...

visual bone
opal lagoon
#

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.

visual bone
#

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

opal lagoon
#

OK, but what you've got there looks like if you press an Enable button, it will unpress the corresponding Disable, no?

visual bone
#

yeah

#

thats how iw anted to use it

opal lagoon
#

My point is really that you don't need two buttons for this where one will do

visual bone
#

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

opal lagoon
#

A given notification is either enabled or it's disabled. it can't be both or neither.

visual bone
#

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

opal lagoon
#

As you add more things to control your GUI will fill up and you'll be glad it's taking less space

visual bone
#

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

opal lagoon
#

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

visual bone
#

no idea how to even do that

#

which is what ill need for this to work and function properly i guess

opal lagoon
#

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.

visual bone
#

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

opal lagoon
#

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.

visual bone
#

that was my exact idea

#

0.2.2 add gui with nice buttons

#

something pretty that is functionalish

opal lagoon
#

If you don't mind my asking, why are you posting screen shots of of code rather than posting the code as text?

visual bone
#

its fast to take a screenshot and i dont know a quick way to insert code

#

is there a quiock way to insert code?

opal lagoon
#

Yes, you copy it... and then you paste it!

visual bone
#

[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?

opal lagoon
#

The trick is getting it to format nicely, which is actually very easy

visual bone
#

oh

#

how do you format it?

timid quail
#

```cs
your code
```

opal lagoon
#

Like this. Start a new line and put 3 ` characters down followed by a cs

#

What he said

timid quail
#

with "cs" being the language you are using (cs = C Sharp = C#)

opal lagoon
#

Listen to quickdrawmgraw

visual bone
#

'''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

opal lagoon
#

Close!

timid quail
#

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

visual bone
#
        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#```
opal lagoon
#

Also don't need the cs prior to the backticks at the end

visual bone
#

haha!

#

thank you

#

thats cool

opal lagoon
#

Just naked backticks

visual bone
#

thast good to know

opal lagoon
#

I mean who doesn't like naked backticks?

timid quail
#

```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

opal lagoon
#

Certainly discord likes them

timid quail
#

so that you get the proper syntax highlighting

visual bone
#

some code

#

thats super easy

opal lagoon
#

Excellent!

#

Now try with some more code where you'll see the syntax highlighting

timid quail
#

you can also do inline code snippets by using `code`

#

like this for example

visual bone
#

mind blown

opal lagoon
#

Yep, great for referring to variables or methods in a comment

timid quail
#

it's basically just markdown

#

the same thing you can use for README formatting on GitHub, for example

#

though it's much more limited here

visual bone
#
            //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);```
opal lagoon
#

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

visual bone
#

I just learned that lol

opal lagoon
#

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);```
visual bone
#
        public ConfigEntry<bool> TNconfig;
        protected bool defaultValue;
        public ConfigEntry<bool> SolarToggleConfig { get; private set; }
        public ConfigEntry<bool> PauseToggleConfig { get; private set; }```
timid quail
visual bone
#

ohh

opal lagoon
#

There's something amiss with how you're putting that in. The syntax highlighting is not coming through

timid quail
#

is your first line this?
```cs

opal lagoon
#

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

visual bone
#

cs test

opal lagoon
#

I'm guessing that's a goof. The 'cs' should not appear

opal lagoon
#

Not Witcraft, but it does involve the dark arts...

timid quail
#

```cs
var a = "abc";
```

#
var a = "abc";
visual bone
#

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

opal lagoon
#

Munix, how to you escape the backticks so they come through in your example?

timid quail
#

it looks to me like you aren't putting the "cs" right next to the backticks

visual bone
#
        {
            // 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);
        }```
timid quail
#

works for any of the formatting characters like *hello*

opal lagoon
#
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);
        }```
visual bone
#

c# helloworld

opal lagoon
#

So that was a
```cs
your code bock
```

visual bone
#

yes

#

does cs need ''cs' code '''

wanton lava
#
string x = "y"
visual bone
#
namespace ToggleNotifications
{
    public enum NotificationType
    {
        SolarPanelsIneffectiveMessage,
        VesselThrottleLockedDueToTimewarpingMessage,
        CannotPlaceManeuverNodeWhileOutOfFuelMessage,
        GamePauseToggledMessage,
        PauseStateChangedMessageToggle,
        None
    }
}

#

HAHA

#

nice

opal lagoon
#

Yay!

timid quail
#

there ya go

#

haha

opal lagoon
#

Now you're gonna be posting like a pro!

visual bone
#

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?

opal lagoon
#

I think they get defaults if you don't

timid quail
#

I don't really understand the first few lines here

#

why do you first use defaultValue and then assign to it

opal lagoon
#

I suspect you don't need that dictionary. It looks like something needed for radio buttons maybe

visual bone
#

hm

#

me trying to remember why i coded it this way and realizing that once it worked i brain dumped the why

timid quail
#

really the default value for a bool toggle should just be "true" or "false"

opal lagoon
#

My guess is that you lifted that from FP

timid quail
#

it's the value that the config option will have when you first launch the game with the mod installed

visual bone
#

so the basic thing im trying to do

timid quail
#

after that it's never used again

visual bone
#

is just have three separate values for three separate config values

#

that dont hold the same value, theyre completely separate

opal lagoon
#

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

visual bone
#
//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?

timid quail
#

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

visual bone
#

good to know

timid quail
#

and if it's not public, there's not really any need to make them properties

visual bone
#

im confused by that

#

if id ont make a property then i can change things in my mod?

timid quail
#

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
visual bone
#

##- 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

timid quail
#

the server had the extra formatting features like lists and headings enabled for some time but then Discord disabled it again

#

no idea why

visual bone
#

weird

timid quail
#

(quoted a wrong message)

visual bone
#

that is nice

timid quail
#

about properties - they basically encapsulate the state of a field

#

for example

visual bone
#

so 99% of what im doing it would be internal

#

well i broke it

#

fuck

timid quail
#

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

visual bone
#

all i did was do crtl + h "public" =>> "internal"

#

now the entire csproj is jacked up

timid quail
#

oh yeah and from the first error: you also changed the "BepInEx.AssemblyPublicizer.MSBuild" package to "BepInEx.Assemblyinternalizer.MSBuild" lol

visual bone
#

fml

timid quail
#

just roll back the changes in the csproj file

#

no need to do anything else I imagine

visual bone
#

how do i do that?

timid quail
#

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

visual bone
#

k maybe this works now

#

or its fucked, not sure

#

phew

#

its fixed

#

thank you

timid quail
#

one thing is, you will want to keep your plugin class public

visual bone
#

yeah i figured that

timid quail
#

and some lifecycle methods also need to be public if they're overrides

visual bone
#

cause the bepinex needs access to it

timid quail
#

like OnInitialized

visual bone
#

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

opal lagoon
#

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.

visual bone
#

well thats enough messing with syntax for today

visual bone
#

FINALLY

opal lagoon
#

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!

visual bone
opal lagoon
#

Love your icon, btw.

visual bone
#

But the 0.2.2 will use it like this

#

I feel like the icon is too small

opal lagoon
#

You can make it bigger pretty easily.

visual bone
#

Via photoshop or just with coding?

opal lagoon
#

I think it may scale to the size of the rect it's given, provided it's bigger than the rect.

visual bone
#

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

opal lagoon
#

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

visual bone
#

Ah makes sense

#

Before 0.2.2 release I'll be slimming the mod down a bit and remove unnecessary pngs etc

opal lagoon
#

That's a good thing to do.

visual bone
#

Yup