[MOD] (Alpha 4) Inventory Panel (v.0.5.1 - June 04, 2014)

Started by Joretap0, May 18, 2014, 08:05:09 AM

Previous topic - Next topic

pawnstorm

Nice mod! This is really useful :). Do you have any ideas yet on how to add it to the HUD? If you want my help, I think I might have some ideas.

Also can I add this to the Vanilla+ modpack? Pretty please? :P
It's going to be just a little bundle of mods as a separate download that I think complement Vanilla+ well and which I do some testing on for compatibility issues.

Joretap0

Quote from: pawnstorm on May 19, 2014, 01:37:00 PM
Nice mod! This is really useful :). Do you have any ideas yet on how to add it to the HUD? If you want my help, I think I might have some ideas.

Also can I add this to the Vanilla+ modpack? Pretty please? :P
It's going to be just a little bundle of mods as a separate download that I think complement Vanilla+ well and which I do some testing on for compatibility issues.

If it stay standalone(just a modpack), there's no problem ;)

For the HUD, i made a lot of test without good result, and to avoid any conflict with other mod, i really don't want to override original class like Architect+ do, so it's really hard.

But there a lot of possibility that i don't try yet, and i'm sure that's possible to find a good solution, but that's take a lot of time to make all these test :/

edit : My last idea that i need to test is to create a "mini-fixed-tab" with the button inside, but first test fail, need to make more test.
I try with a "mini-fixed-dialog" with "absorbAllInput = false" and "closeOnEscapeKey = false" but these 2 vars don't seems to work, or i miss something :/

If you have any good ideas, i'll take them ;)
My Mods : Dresser | Inventory Panel | Cannibal
Sorry for my english ;)

pawnstorm

#17
It'll be just an archive with a small collection of mods which I've tested for compatibility, each mod in its own directory with all the original files and nothing added. Is that alright?

Just a braindump of some ideas on how to add it to the HUD:

First, you'll need a place where it draws your HUD-element. I can think of 2 options:
You can extend TabInspect and replace Find.MainTabsRoot.tabInspect with your extended class, kinda like I did with TabArchitect. Then make a function to draw your stuff and override PanelOnGUI to also call your function. Maybe you could integrate a button or something into the inspectorpane, if you check (Find.Selector.NumSelected > 0) before you draw it'll only display the button when something(s) is/are selected.
Or you can try to add it to the LayerStack. I'm not sure how those work, but adding it seems simple: Find.Layers.Add(your layer extended class). And then just put the draw stuff in YourLayer.LayerOnGui().

Then for the tricky part, which is adding your custom tabinspect/layer to the UI. There's the trick I used in architect+, using the incidentmakerclasses, but you wanted a different solution. Also, using the incidentmaker classes would obviously make it incompatible with Architect+/Vanilla+.
I think it's impossible to do this without atleast overriding some original class and replacing it in an xml file. Preferably one that gets instantiated at the right time, but I can't think of any besides the incidentmaker classes. I'll attach 2 textfiles with some grepresults of all the unique classes referenced in the core xml files, perhaps you have better luck.
It might work too if you can find a class that gets used atleast once before the game UI is displayed. Perhaps you can override one of the sound classes and add it to a certain sound.
In the sound class, just extend the original class, and add a static constructor that adds your TabInspect/Layer to the GUI. Then, add a destructor to your custom TabInspect/Layer class that checks if it should add itself again (for TabInspect you could check if Find.MainTabsRoot.tabInspect is of the original TabInspect class again, if you took the Layer approach, check if Find.Layers.FirstLayerOfType(YourCustomLayer)==null). Maybe you'd also need to check if your mod's still active just in case someone unloads it.

Edit: Maybe it'd also be a nice idea to create like a wrapper mod library that any mod can use to trigger their class on the incidentmaker class and/or some static trigger in another class that loads early. That way, multiple mods can use the same trigger.

[attachment deleted by admin: too old]

Joretap0

 ;D Yeeahhh...

Finally i made it, i've added a button to the HUD without any override...
The first method that i use was the best, just a little thing that i missed!
So i use the Layer method, the bug i had before was that camera cannot scroll anymore when i draw it.
I finally find the "PreventCameraMotion" in LayerStack, and a special class of layer named "EditWindow" that allow to print a layer without fixing camera :)

So tomorrow i'll update the mod with an HUD button, to late to do it now.
My Mods : Dresser | Inventory Panel | Cannibal
Sorry for my english ;)

pawnstorm

Ah, awesome job! Looking forward to the new version :)

Joretap0

Version 0.3 online, there's now an "Inventory" button in top-right of your HUD ;)
Note that server where i store my files is crashed, so i attach the .zip to the mod post.
My Mods : Dresser | Inventory Panel | Cannibal
Sorry for my english ;)

pawnstorm

Ah, you got it working, nice! I don't understand why you add the button to the layerstack in the TickRare() method though, doesn't that keep adding new layers to the layerstack every 5 seconds?
Perhaps you can do it in SpawnSetup(), that way you also don't need the InitializeMod(). You could remove it from the layerstack in DeSpawn(), and maybe add a placement restricter for it so that people can only build one Inventory Panel.
I'd much prefer if it didn't require a building though, seems a bit odd to me to have to build something to view my inventory.
Another suggestion, maybe you could also use the command icon you used on the building as an icon on the HUD. If you could squeeze it in next to the "Toggle visibility of zones" icon (below the normal speed icon) I think that'd be perfect.

Joretap0

I use the tickrare cause at the first tests, button dissapear when you escape to game menu, so like that, it was reapparing after 5 sec max.
But it seems that with the editWindow, it's not disapear while entering game menu, so i will change that on the next version.
Note that the window is exclusive, so it doesn't be relaoded anytime.

For the button, my first idea was to set it near the "toggle visibility button", but i'm not a graphist, and i need someone to make a good icon button that mean inventory(screen button don't be enough explicit for me).

For the building requirement, it's the only way that i find to load .dll without overriding any vanilla class.
My Mods : Dresser | Inventory Panel | Cannibal
Sorry for my english ;)

pawnstorm

I think I found a way to add the inventory panel to the HUD without needing to override a vanilla class or use a building. Is it ok if I try to add this to your mod and then send you the files? You can do anything you want with my code, I don't need credit for it or anything.

Joretap0

If you find that, i'll be really grateful.
To do that, we need to find an class used at game start and where we can add new defs.
My Mods : Dresser | Inventory Panel | Cannibal
Sorry for my english ;)

pawnstorm


Celthric Aysen

wow Pawnstorm, Joretap0 making rimworld a better game :P
you guys should work together more.
My DeviantART|E-Vehicles|Flebe's  Channel
"♫"Every people that i see i will never understand"♪"

Joretap0

Quote from: pawnstorm on May 21, 2014, 11:11:07 AM
I got it working, I sent you a private message :)

Thx, i will look at that.

Finally it will be necessary that i remove this raretick, cause i just remark that, for example, when in build mode building a wall, it make lost the mouseclicked :/
My Mods : Dresser | Inventory Panel | Cannibal
Sorry for my english ;)

Joretap0

Version 0.4 online, no more inventory panel item needed, so destroy them before updating your mod.

And great thanks to pawnstorm that made this update.
My Mods : Dresser | Inventory Panel | Cannibal
Sorry for my english ;)

pawnstorm

Nice! You left the source in though, not sure if you meant to do that. Also, there are 2 InventoryPanel directories?