Jump to content

Spec mod


badosu
 Share

Recommended Posts

For some time now I've been wanting to make a spec mod. Currently the 'chrome', 'dashboard' or whatever the overlay is named provides little insight to what the player is doing. This is true for both players and specs.

This is the benchmark I'd use, notice the production pane on top-left as well, income rate besides resource amounts on mid bottom and military upgrades on its right:
 

The first step would be to implement the production overlay, the icons should be easy to display, just run a query over all production facilities to return the units, their amounts and the researching technologies. Would also be disabled for players, just enabled for specs at first.

Ultimate goal would be to replace all of the current overlay with a minimal one with more relevant information on display, and also an alternate version for players.

One blocker I could see are queries and their calculation taking a lot of CPU on each tick due to inefficient model or something similar. Otherwise I don't think there should be too many blockers

I made this thread to ask if anyone has any suggestions, insights or tips on how to perform it (e.g. code I can look at for reference), thanks!

Edited by badosu
  • Like 5
  • Thanks 1
Link to comment
Share on other sites

I guess  @nani and @ffffffff might have some insights.

You need to look into binaries/data/mods/public/gui for the files you'll need to change (probably session.xml and session.js) Getting the resources should be easy.; Best of three kinda impossible since you wouldn't know that, time is already implemented, just a matter of position,

For the production queue, might be a bit more tricky.

Link to comment
Share on other sites

Should be easy, look at @ffffffff fgod mod code,  specially at the stats overlay  and the statistic window where he added the techs list. As for performance try doing it the naive way and limit it every 1 sec or so, in the case  of taking too much many ms try doing partial updates. I suspect  the actual rendering of text changing all the time will be the most expensive part so take that into account too.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Does anyone know if it's possible to query all units on production queue without passing an entity?

Alternatively, if it's not, how can I make a query for all trainable entities (e.g. barracks, cc, fortress, etc)?

This might work: `Engine.GetEntitiesWithInterface(IID_ProductionQueue)`

Edited by badosu
Link to comment
Share on other sites

Well, I don't want to query on every update, instead doing something similar as what TechnologyManager does on the technology progress widget on the right side.

From what I've seen, I can use the ResearchProgress widget as a scaffold for the gui. For the production I can patch the ProductionQueue for units and TechnologyManager for techs to manage new/finished units/techs on a new ProductionManager. The ProductionManager will be responsible for managing the items to be displayed/updated/removed. Additionally I can try using what seems like an event bus that's already being used to decouple from the implementation.

Now only need to figure out how to do the same for unfinished buildings without querying often.

Edited by badosu
Link to comment
Share on other sites

It depends, if it's as inexpensive as the other widgets already present there's no need to. If I can't find an efficient solution for the missing parts then I might throttle it (but definitely not 5 seconds :laugh:). The techs and units part is fine since they register/update/deregister to the ProductionManager, now only to unfinished buildings.

Edit: for structures it seems I can listen to events: "ConstructionStarted", "MT_FoundationProgressChanged", "MT_ConstructionFinished"

Edited by badosu
Link to comment
Share on other sites

you cant set styles dynamically, they are processed when the gui is loaded but there isnt code that handles it when the object style is modified from js

you can however change the font and color as xml in the text with js

Edited by nani
Link to comment
Share on other sites

  • 2 weeks later...

Hello, I've been trying some approaches to the production queue overlay.

So, the quick and dirty method would be to iterate over all players entities with ProductionQueue and query the production queue there.

However I would not like to do that as it would be very inefficient.

Instead I've been trying to hook onto Trigger, specifically the event "TrainingQueued" called here (https://github.com/0ad/0ad/blob/1dc4682ce83f316437ded12032859d709e227ca5/binaries/data/mods/public/simulation/components/ProductionQueue.js#L345-L351)

Unfortunately it seems that I can't hook onto the trigger class as exemplified by the triggers demo scenario (https://github.com/0ad/0ad/blob/master/binaries/data/mods/public/maps/scenarios/triggers_demo.js)

I wasn't able to do that by registering with a new simulation component, neither by a custom component inside session/. Can anybody give any pointers?

Also, it seems that by hooking or modifying any of these files I might trigger an OOS if the players don't have the mod? Can anybody tell me if this plan is not feasible?

Link to comment
Share on other sites

Some progress:

The buttons also have tooltips, which is quite helpful to know how many seconds it's missing to finish and the unit name. Additionally I'm considering to click on button to move to recruiter entity but that should take some effort.

I'd like to improve the visual side though, in particular I want to make the left indicator (the vertical bar) with rounded borders.

Most importantly I want to make put the same kind of canvas around the progress bar as the button has, any pointers would be welcome.

Screenshot from 2020-07-22 20-15-32.png

  • Like 1
Link to comment
Share on other sites

Serral is love, Serral is life.

Does anybody know how to select an entity? I've tried stealing `ResearchProgress` code for that: (https://github.com/0ad/0ad/blob/1dc4682ce83f316437ded12032859d709e227ca5/binaries/data/mods/public/gui/session/ResearchProgress.js#L91). I noticed that it uses `EntitySelection.selectAndMoveTo` from the object instantiated in `session.js` passing `g_Selection` as the instance.

I've tried using `g_Selection.selectAndMoveTo` but it seems that the global for some reason has no methods. I've also tried instantiating a new EntitySelection but it doesn't work too.

Link to comment
Share on other sites

If I can make the button selection work to move to the entity training/researching/building I can make an early release of the mod.

Everything else is working reasonably as I want, apart from minor visual adjustments I want to perform.

Link to comment
Share on other sites

Well, `Engine.CameraMoveTo` will suffice for now.

This is an early release, much of the code was borrowed from @leitoso's https://gitlab.com/xxleite/specmod. Kudos!

It works for specs and also for players. For specs unfortunately, given the chat messages and hero buttons the position is a bit awkward, but should be usable.

There are many adjustments necessary yet, like making the progress bars brighter for darker player colors, rearranging gui items other than the prod mod, hotkey and menu option for enabling/disabling production etc...

These are on the backlog, as well as making an option to show all current units from players using the same system.

Hope you find it useful.

prodmod.pyromod

  • Like 2
Link to comment
Share on other sites

Hmm... it seems the colormap is not working  as expected. I copied it so I am not really familiar with, I'll find a solution and upload the fix.

Are you using some kind of mod that changes players colors?

I've specced some games already and the only error I had was when I resigned as a player so I am not sure how to reproduce.

Edited by badosu
Link to comment
Share on other sites

Feedback:

- I no got errors;

- Have to decrease the size a little bit, it’s reaching to the civ shield;

- It would be interesting to show only the population of soldiers, alongside the total population;

- Just below in the left corner, show the techs that are being searching by the players.

Overall it's very good, congratulations.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...