badosu Posted July 3, 2020 Report Share Posted July 3, 2020 (edited) 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 July 3, 2020 by badosu 5 1 Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 3, 2020 Report Share Posted July 3, 2020 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. Quote Link to comment Share on other sites More sharing options...
nani Posted July 3, 2020 Report Share Posted July 3, 2020 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. 2 1 Quote Link to comment Share on other sites More sharing options...
badosu Posted July 10, 2020 Author Report Share Posted July 10, 2020 Is the dream real? cc @leitoso 4 Quote Link to comment Share on other sites More sharing options...
badosu Posted July 11, 2020 Author Report Share Posted July 11, 2020 (edited) 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 July 11, 2020 by badosu Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 11, 2020 Report Share Posted July 11, 2020 You can query the player then query all its entities I think. Quote Link to comment Share on other sites More sharing options...
badosu Posted July 11, 2020 Author Report Share Posted July 11, 2020 (edited) 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 July 11, 2020 by badosu Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 11, 2020 Report Share Posted July 11, 2020 You could also keep track of the time, by querying the current date? And only call the function every five second or so. Quote Link to comment Share on other sites More sharing options...
badosu Posted July 11, 2020 Author Report Share Posted July 11, 2020 (edited) 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 ). 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 July 11, 2020 by badosu Quote Link to comment Share on other sites More sharing options...
badosu Posted July 11, 2020 Author Report Share Posted July 11, 2020 By the way, can I set styles dynamically? I see that fonts and some sizes are set in xml files, that would not be optimal as I would want to implement some sort of scaling feature later on. Quote Link to comment Share on other sites More sharing options...
Stan` Posted July 11, 2020 Report Share Posted July 11, 2020 23 minutes ago, badosu said: By the way, can I set styles dynamically? Dunno have you tried Engine.GetGUIObjectByName("guiobjectname").style = ? 1 Quote Link to comment Share on other sites More sharing options...
nani Posted July 11, 2020 Report Share Posted July 11, 2020 (edited) 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 July 11, 2020 by nani Quote Link to comment Share on other sites More sharing options...
nani Posted July 11, 2020 Report Share Posted July 11, 2020 also https://code.wildfiregames.com/D920 Quote Link to comment Share on other sites More sharing options...
badosu Posted July 22, 2020 Author Report Share Posted July 22, 2020 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? Quote Link to comment Share on other sites More sharing options...
badosu Posted July 22, 2020 Author Report Share Posted July 22, 2020 (edited) Well, quick and dirty it is then: The sharpness of the text leaves to be desired, I wonder if there's a way to improve it. Edited July 22, 2020 by badosu 1 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted July 22, 2020 Report Share Posted July 22, 2020 Gotta use the correct font weight in the code? 1 Quote Link to comment Share on other sites More sharing options...
badosu Posted July 22, 2020 Author Report Share Posted July 22, 2020 Is it possible to add sprites and styles without having to copy paste the whole vanilla `gui/session/{sprites,styles}.xml`? Quote Link to comment Share on other sites More sharing options...
badosu Posted July 22, 2020 Author Report Share Posted July 22, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
badosu Posted July 23, 2020 Author Report Share Posted July 23, 2020 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. Quote Link to comment Share on other sites More sharing options...
badosu Posted July 23, 2020 Author Report Share Posted July 23, 2020 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. Quote Link to comment Share on other sites More sharing options...
badosu Posted July 23, 2020 Author Report Share Posted July 23, 2020 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 2 Quote Link to comment Share on other sites More sharing options...
badosu Posted July 24, 2020 Author Report Share Posted July 24, 2020 (edited) 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 July 24, 2020 by badosu Quote Link to comment Share on other sites More sharing options...
badosu Posted July 24, 2020 Author Report Share Posted July 24, 2020 Since we're touching this topic, is it possible to add a sprite with programatic color added? It could be a full alpha sprite with addEffect color if possible or something similar. Quote Link to comment Share on other sites More sharing options...
borg- Posted July 24, 2020 Report Share Posted July 24, 2020 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. Quote Link to comment Share on other sites More sharing options...
badosu Posted July 24, 2020 Author Report Share Posted July 24, 2020 The resources overlay is part of leite's mod. Mine is just the production for now, researching techs are displayed with the other production items (techs, buildings, units). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.