Bay 12 Games Forum

Dwarf Fortress => DF Modding => Utilities and 3rd Party Applications => Topic started by: klassekatze on April 27, 2016, 02:25:49 pm

Title: Adventure mode: No inventory viewscreens?
Post by: klassekatze on April 27, 2016, 02:25:49 pm
So I thought I'd take a stab at making a better inventory interface because, well, I'm sure you can imagine why. Figured it would be pretty straightforward, just grab the viewscreen, read its variables, whack the keys...

Nope. dfhack.gui.getCurViewscreen() doesn't seem to have much of any relationship with what you are doing in adventure mode, be it having the interact menu open or 'wear' or whatever. It is always dungeonmodest and it doesn't know anything about the open menu. df.global.ui_advmode does but I can't find anything in it that gives detail on inventory or world action related menus other than that one is open.

I don't want to act on the unit inventory or the tile directly (or at least not blindly) if I can help it because then a user might unknowingly be able to do something that wasn't actually possible through the standard interface. I'd prefer to route through the legitimate UIs (albeit in the blink of an eye) and thus use Toady's SAN checks. Particularly on things like 'g' that have contextual stuff like campfires or grabbing snow.

Now, obviously I can just screen scrape and parse the text and determine what actions are there and keys but that would be a big pile of ugly string manipulation I'd like to avoid. So if anybody knows about a better way I'm not seeing, please share.

Title: Re: Adventure mode: No inventory viewscreens?
Post by: mifki on April 27, 2016, 06:02:54 pm
Yeah, dfhack support for the adventure mode is minimal.
Actually I wanted to create a thread to ask dfhack guys - is that right, or I just also was looking in a wrong place? Any plans for a better support for the adv mode?
Title: Re: Adventure mode: No inventory viewscreens?
Post by: Warmist on April 27, 2016, 11:18:17 pm
Yeah, dfhack support for the adventure mode is minimal.
Actually I wanted to create a thread to ask dfhack guys - is that right, or I just also was looking in a wrong place? Any plans for a better support for the adv mode?
Yeah adv mode suffers from lack of attention.

@klassekatze: i think way easier way to do that is just look over adventurer items and make your own gui without basing anything on vanilla screens. Inventory management is easy enough to rewrite from ground up.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: klassekatze on April 28, 2016, 02:44:49 am
Spoiler (click to show/hide)
Made a bit of progress with this, I think.
@klassekatze: i think way easier way to do that is just look over adventurer items and make your own gui without basing anything on vanilla screens. Inventory management is easy enough to rewrite from ground up.
Yep, that's my plan. I'm afraid that leaves esoteric bits like snow and filling water and whatnot hanging out to dry but I can at least do picking up items in the same square with confidence (that it won't be accidentally cheating).

It was never about basing it on the screens, so much as whatever secret rules they use to decide "can i make a campfire to the northwest" and so on, not to mention actions I'm not aware of.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: Warmist on April 28, 2016, 05:25:21 am
Imo the campfires and other interactions are placed very wrongly as you need to go through (in a very small list) over very different things. Also i just now understood that you are building external gui.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: klassekatze on April 28, 2016, 10:34:23 am
External gui, internal gui... I considered internal but I wanted drag and drop and so on. It was easier to build a series of remote calls and slather on a dozen javascript frameworks. Everything important is going to be html/javascript in this. As a side benefit anyone and their dog can edit html/javascript so the more flexible functions I add the easier quick and dirty DIY GUIs of various sorts should be. Or personal stylistic changes.

I think I might take a cue from the suggestions thread and also stick a stocks page in here somewhere.

As for interactions, I might just do a "Interact" button that builds a menu by screenscraping and scrolling through that particular action list when pressed. ...And then does it again to get to and activate the chosen interaction. Troublesome, but c'est la vie.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: lethosor on April 28, 2016, 05:45:34 pm
The main adventure mode viewscreen simply doesn't contain very much information. That's how it's implemented in DF - it doesn't have anything to do with a lack of DFHack support for adventure mode. A lot of adventure mode data is stored in various globals instead, like ui_advmode.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: mifki on April 28, 2016, 05:49:40 pm
The main adventure mode viewscreen simply doesn't contain very much information. That's how it's implemented in DF - it doesn't have anything to do with a lack of DFHack support for adventure mode. A lot of adventure mode data is stored in various globals instead, like ui_advmode.


Sure, I was talking about ui_advmode, most fields of which are unknown.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: lethosor on April 28, 2016, 06:25:06 pm
Here (http://imgur.com/a/413mX/embed#1) are some screenshots from someone else's attempt at making an inventory screen, from http://www.bay12forums.com/smf/index.php?topic=139553.msg5505747#msg5505747
I couldn't find code for it, but it looks like df.global.world.units.all[0] is the adventurer, and its "inventory" property should give you whatever the inventory screen lists. Contained items may be referenced from individual items in the list but not in the list itself.

Anyway, I encourage you to put whatever you come up with on Github, to make it easier to integrate into DFHack if it reaches that stage, or at least to help other people looking to accomplish similar things. (If Rafal99 had done that, it would save a lot of time.)
Title: Re: Adventure mode: No inventory viewscreens?
Post by: klassekatze on April 28, 2016, 09:24:57 pm
I've actually been using units.active[0], though its probably in both places.
I've actually finished the inventory in and of itself. Drag and drop actually moves things wherever they ought to be in df, right click equip also working using a block of code straight from forceequip. (except for weapons, for some reason, though i can't wear those in game either w/out drop & pick up - a bug maybe? don't care enough to look it up). I could hardcode the weapons if it comes to it.
 
Spoiler (click to show/hide)

I'm undecided as to whether to do eating/drinking, items on ground, or some sort of realtime health display next.
Anyway, I encourage you to put whatever you come up with on Github, to make it easier to integrate into DFHack if it reaches that stage, or at least to help other people looking to accomplish similar things. (If Rafal99 had done that, it would save a lot of time.)
I do plan to upload all this to github or something eventually. Would be a terrible waste otherwise. Probably once I can pick up/drop stuff vs the ground, at least, maybe?
Title: Re: Adventure mode: No inventory viewscreens?
Post by: Max™ on April 28, 2016, 09:43:13 pm
Uh, df.global.world.items.other.in_play has everything I've needed to manipulate items without touching my units.active[0].inventory field. I generally sort through the other fields under items.other though since I'm usually after a certain category of item and can find it via the lists there by just checking the most recently modified ones at the bottom. I had to do a lot of this when I was figuring out artifake, and later used similar tricks to gm-editor some items into containers and later to put entire units into containers so people could drink themselves.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: lethosor on April 28, 2016, 10:01:35 pm
The name doesn't make it sound like it's restricted to items belonging to the adventurer, while units.all[0].inventory definitely is. I could be misinterpreting "in_play", though.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: klassekatze on April 28, 2016, 10:21:55 pm
I think Max is talking about manipulating inventory across a fortress/the whole scene. So far I'm manipulating inventory of a unit - the adventurer. Like stuff in my backpack.

In case you did mean my units inventory, Max, you should knew that the unit inventory field has additional information like Worn or so on that isn't stored in the type of object that is in other[]. You would end up referencing it anyway if you wanted to distinguish between a gauntlet in the hand and a gauntlet ON the hand. Which could literally be the difference between life and death.

For stuff on the ground, in play makes more sense.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: Max™ on April 29, 2016, 07:21:22 am
I meant stuff on the ground/in buildings/held by others, though playing with the inventory worn types lets you do silly things like wear swords on your head or a barrel on your foot.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: klassekatze on April 29, 2016, 07:09:08 pm
Anyway, I encourage you to put whatever you come up with on Github

https://github.com/klassekatze/dwarfgui (https://github.com/klassekatze/dwarfgui)
https://github.com/klassekatze/dfhack (https://github.com/klassekatze/dfhack)

As it stands:
Spoiler (click to show/hide)

Yeah I dunno. It works but now I'm kind of flagging in interest (Adventure mode makes me kinda mad because the feedback is nonexistent. You swing the sword at the easiest, most solid bodyparts and they always dodge and bleed you out somehow even if you are in iron and a demigod and you have no idea why...)

That being said, it is very trivial to expand this based on the functions I have implemented for inventory to bridge any arbitrary code in a plugin all the way to Javascript in the webpage. Even if the programmer doesn't like Go, they can just bang on the boilerplate until they get that much in and the rest is web design cake.

In other words can easily be expanded into a external GUI for just about anything in Dwarf Fortress adventure mode or otherwise, even if my interest falls out.

I don't know if I should bother with a proper thread/release for this yet when all it does is allow you to observe/search/reorganize adventurer inventory and equip items.
Title: Re: Adventure mode: No inventory viewscreens?
Post by: lethosor on April 30, 2016, 02:49:51 pm
Uh, wow. I was expecting something within DF. Looks neat!