Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: [0.95a] Dialog Minimap  (Read 5628 times)

andylizi

  • Ensign
  • *
  • Posts: 11
    • View Profile
[0.95a] Dialog Minimap
« on: December 14, 2021, 03:39:30 AM »

Dialog Minimap



This mod shows a minimap besides the dialog when it asks you to accept a mission. It's the same map as the one on Intel screen, with fuel range, accepted mission icons, etc.
That's all it does. It's a utility mod and can be added or removed at any time.

NOTE: This mod is unnecessary in 0.95.1a and above. See below.


Download: https://drive.google.com/drive/folders/1eV-lnIwCSDIWPLJ0-2dGed6yoLugwfmF?usp=sharing

Source code: https://github.com/andylizi/starsector-dialog-minimap

FAQ

Why?

Because I'm tired of going through series of "See mission -> Note down the star name -> Decline -> ESC, ESC -> Open Intel -> Find the star with that name -> Show on map -> Decide whether to accept -> Go to the bar -> Click on the mission -> Continue, continue -> Finally accept" every damn time.

Wait, doesn't vanilla already have this feature in 0.95.1a?

Ah, yes. Yes it does.

So for those who are interested, here's the timeline:
  • Dec 6: I started making this mod.
  • Dec 9: I had a working prototype.
  • Dec 10: 0.95.1a released. I looked at the patch notes and thought, "Hmm, no big deal, it's shouldn't be too hard to make my mod compatible with the new version, too". Famous last words.
  • Dec 13: Finally done, almost! I added all the details I want, fixed some bugs, tested it on 0.9.1 and fixed some more bugs, tested it some more. Now, the only thing left to do is to test it on the new 0.95.1a release!
    …Wait a second, why are there two maps?! Don't tell me...
Quote
Missions will present the player with a map showing the initial destination/mission target's location.
                 — From the patch notes that I haven't looked at too closely the first time

this is how the game looked, with 0.95.1a + my mod
[close]
That's some really, really unfortunate timing... So after I came to terms with reality, I decided to release this anyway. Maybe it can be useful to those who are playing older versions?

Needless to say, you don't need this mod if you're playing 0.95.1a or above.

How does it work? / Why doesn't it work for [...] mission?

Originally I'm going to go into a lot more details on this, but now I'm tired and just want to get this over with. I'll be brief.
  • Every time a player clicks an option, the program checks if there're new options starting with "Accept". If it does, it's probably a mission. This means if a modded mission doesn't use "Accept ..." for confirmation, the map's not going to show.
  • Then, it scans the "memory" for items that look like "$xx_systemName", which is a convention almost all vanilla missions follow to store names of the destination system. If a modded mission doesn't use these, the map's not going to show. It's possible to avoid this limitation by scanning the text for every star systems, but that can get expensive computationally.
  • Then, it looks at the last paragraph for appearances of these system names, and only continue if one of them actually appears in the text. This is to avoid situations like a) "buy this blueprint location for X credits" and the mod just shows you the location without paying XD and b) there're multiple mission choices and the program doesn't choose the correct one.


« Last Edit: December 25, 2021, 07:06:45 PM by andylizi »
Logged

Helldiver

  • Captain
  • ****
  • Posts: 377
  • space fruit
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #1 on: December 14, 2021, 04:09:20 AM »

Thank you for releasing it anyways, as it will be very handy for people who stay on 0.95a for mod reasons.
Logged
Afflictor bean plushie that glows purple when you squeeze it
30$

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #2 on: December 14, 2021, 05:01:02 AM »

Amazing mod, I applaud your technical prowess. This is going to be a great example of how to extend vanilla functionality in a way Alex didn't expect.

The more orthodox way of it would probably be via a MapAwareDialog class extending RuleBasedInteractionDialogPluginImpl, and hooking it via rules.csv. Still, can't guarantee it would work as well as yours. This would avoid having to inject it mid-way, and having to deal with reflection (which I find your use of really educational, especially the trick with OptionDelegateProbe).

Either way, great stuff. Been feasting on your code for a while now :)
Logged

andylizi

  • Ensign
  • *
  • Posts: 11
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #3 on: December 14, 2021, 05:41:33 AM »

Amazing mod, I applaud your technical prowess. This is going to be a great example of how to extend vanilla functionality in a way Alex didn't expect.

The more orthodox way of it would probably be via a MapAwareDialog class extending RuleBasedInteractionDialogPluginImpl, and hooking it via rules.csv. Still, can't guarantee it would work as well as yours. This would avoid having to inject it mid-way, and having to deal with reflection (which I find your use of really educational, especially the trick with OptionDelegateProbe).

Either way, great stuff. Been feasting on your code for a while now :)

Thank you for your kind words! Yeah, now that I think about it, extending RuleBasedInteractionDialogPluginImpl is definitely less hacky than my approach. Although it probably wouldn't save me much time, since constructing and configuring the map component is the much more difficult part. Without a proper API there's no way to completely avoid reflection, unfortunately.

Actually, my original attempt is even more extreme: I thought the only way to modify the UI is using javaagent + ASM to inject bytecode, like what Minecraft mods do… Fortunately I quickly found out there's a thing called reportShownInteractionDialog() that can potentially make it work using "just" reflection, so that's good I guess. The half-written code for that approach can be found in the "javaagent" branch of the repo, if anyone's interested.
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #4 on: December 14, 2021, 06:42:24 AM »

Amazing work!

Also, you are a prime contender for "most unfortunate mod release 2021". My condolences :P
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23947
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #5 on: December 14, 2021, 10:34:28 AM »

I feel like I should apologize - so, ah, my sincere apologies :) This is really impressive work, regardless!
Logged

IonDragonX

  • Admiral
  • *****
  • Posts: 816
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #6 on: December 14, 2021, 04:18:45 PM »

Amazing work! Also, you are a prime contender for "most unfortunate mod release 2021". My condolences :P
@andylizi
I agree with SirHartley! You did an amazing bit of coding and took initiative on something that has been an issue for at least a year or, probably, more. Certainly, I don't have the experience needed to code what you did.

Please don't let this discourage you from your future creative endeavors.
Logged

Jackundor

  • Commander
  • ***
  • Posts: 242
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #7 on: December 28, 2021, 02:42:05 PM »

lmao
Logged

Netu

  • Ensign
  • *
  • Posts: 6
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #8 on: December 28, 2021, 03:58:17 PM »

Still super useful for any of us waiting for other "important" mods to update to the latest version!  So thanks, regardless!  Hopefully you learned a few tricks coding/otherwise from this?  :D
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: [0.95a] Dialog Minimap
« Reply #9 on: December 29, 2021, 03:43:25 AM »

There's many people still using 0.9.1a so perhaps it could be advertised as such? 0.9.1a and 0.95a "backport" of a crucial functionality.
Logged