OpenXcom Forum

Modding => Work In Progress => Topic started by: Markus Ramikin on January 25, 2015, 09:52:40 am

Title: minimod: Elerium and Alloys Listed on Top
Post by: Markus Ramikin on January 25, 2015, 09:52:40 am
Code: [Select]
items:
  - type: STR_ELERIUM_115
    listOrder: 1
  - type: STR_ALIEN_ALLOYS
    listOrder: 2

Am I the only one around who wishes checking how well supplied all bases are in Elerium and Alloys, for fuel and manufacturing purposes, was more convenient? Depending on how much other stuff is on each base, finding the entries in the Stores or Sales lists gets a bit annoying, especially if you use multiple bases and need to check them fairly often. I've often wished that the amount of Elerium was displayed under the amount of Money in the main base screen.

Well, with the above, Elerium and Alloys are always on top of the list in Stores, easy to find.

I'm almost embarassed to post something so minimal and trivial-looking, but the change in convenience has been enough for me that I wanna share. In fact, I think this would be a nice addition to the pre-installed mods or Advanced Options (and most of those are pretty small too). So putting this up in case I'm not crazy the only one to think so.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: hellrazor on January 25, 2015, 11:23:34 am
May conflict with the 80 Item Limit? (There are player who use it.)

But otherwise a good Idea.

We also could be haveing a drop down category menue like in the manufacture screen.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: Markus Ramikin on January 25, 2015, 12:39:27 pm
You mean, because it would cause elerium pods to spawn instead of weapons on base defense?

Hm, I'll have to test that. But if so, putting them at the bottom of the list instead of top would be about just as convenient (one extra click gets you there) and avoid that problem.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: hellrazor on January 25, 2015, 01:22:35 pm
You mean, because it would cause elerium pods to spawn instead of weapons on base defense?

Hm, I'll have to test that. But if so, putting them at the bottom of the list instead of top would be about just as convenient (one extra click gets you there) and avoid that problem.
Exactly :>
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: Markus Ramikin on January 25, 2015, 10:24:42 pm
Tested, and this didn't happen for me in my latest base defense. Listing them on top seems safe.

Which makes sense, since the 80-limit mod only applies that limit to craft, and has nothing in it about bases.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: CryptoCactus on January 26, 2015, 09:20:29 pm
The original game had a 170-item hardcoded max for spawned items (source (https://www.ufopaedia.org/index.php?title=OBPOS.DAT)). I don't believe that's an issue anymore with OXC though.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on January 27, 2015, 12:05:07 am
Just tried your idea as I agree with your point about hunting to find the elerium and alien alloys in your stores but the following happened. After a mission ends the game crashes to the desktop. I used oxc ruleset editor to implement "list order" 1 & 2 respectively, I also made UFO power sources as 3 and 4 for UFO navigation. Have I done something silly? See the attachments. The only way it seems to stop the crashing is to reinstall an unedited Xcom 1 ruleset. It doesn't seem to help if u just delete the above changes.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: Markus Ramikin on January 27, 2015, 12:20:39 pm
Beats me! I've never used the ocx editor, so I don't know how well that works. And I don't mess with Xcom1ruleset. I just wrote it as a separate mod.

I now attached it to my original post, so if you like, try using that file, enable it in mods, and see if that works better for you? (Hopefully you won't need to go back to a savegame from before you made your change).
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on January 27, 2015, 02:30:31 pm
Thanks for the .rul file, that seems to work ok, was also able to add on ufo ps and ufo nav as 3 & 4 in the list order. If I've time and can be bothered I might redo the whole list order as some of the items are a bit out of place in stores. Also with the 170 limit not applying to OPXC u might as well do something completely right instead of piece meal. This will take quite a bit of time as atm I've got 56 different items in my stores @ base 1 but I'll need to plan out the order carefully as it'll be a case of how many items could I have @ any base.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on January 27, 2015, 02:43:11 pm
Further point I forgot to add is wud it not be possible to do what I'm suggesting but split the stores up into different sections like manufacturing?
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on January 28, 2015, 01:19:03 am
Here's what I've got so far and a brief test on my current game seems to have it working ok. However the way I wud imagine it in completion wud be the equivalent of 14 sections worth of items in one long list as I'm not sure how u wud implement having it in sections like manufacturing. Atm my knowledge of editing .rul files is very limited and on a trial by error basis. But thanks 4 putting me onto this idea and feel free to tweak with this urself. I'm trying to put everything in alphabetical order so that's why "Aegis Fuel" from XOP'S great mod is last @ the minute as it's called XCF_FUEL, go figure but I'm not going to change every mention of Aegis Fuel in Xeno Ops to XCF_FUEL just to fit one line in a highly experimental mod.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: Dooh on January 30, 2015, 03:31:20 pm
Hi there,
The idea to show amount of Elerium and Alloys in main base screen is very good. Actually there is no need to know how much money you have from the main base view. This information is almost at every submenu - manufacture, purchase, sell, even on geoscape after enabling Show Funds in game options.
I did some digging in the code and changed funds info to Elerium and Alloy info. Unfortunately there is no place for two lines and adding also funds to the same line might be too long.

To apply this modification you need to edit BasescapeState.cpp file with below code and recompile.

Code: [Select]
ADD AT TOP OF FILE:
#include "../Savegame/ItemContainer.h"

REMOVE THIS:
        _txtFunds->setText(tr("STR_FUNDS").arg(Text::formatFunding(_game->getSavedGame()->getFunds())));


ADD THIS:
        const std::vector<std::string> &items = _game->getRuleset()->getItemsList();
        for (std::vector<std::string>::const_iterator i = items.begin(); i != items.end(); ++i)
        {
                int e115;
                int alloy;
                std::wostringstream ss, ss2;
                if (*i=="STR_ELERIUM_115")
                {
                        e115 = _base->getItems()->getItem(*i);
                }
                if (*i=="STR_ALIEN_ALLOYS")
                {
                        alloy = _base->getItems()->getItem(*i);
                }

                ss << e115;
                ss2 << alloy;
                        _txtFunds->setText(tr("E>{0}, A>{1}").arg(ss.str()).arg(ss2.str()));
        }

Result is like below.
PS. As I am not a C++ programer the code might be a little clumsy. Also sorry for my English, it's not my first language.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: Markus Ramikin on January 30, 2015, 03:39:52 pm
Wow, C++ got a lot uglier since I last bothered with it (which admittadly is a loong time ago).
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on February 22, 2015, 02:42:53 pm
Based on ur original idea I expanded this to cover all items in my current game. ITEM LIST ORDER.rul is now complete so I throw this .rul file to the community for thoughts, comments or suggestions. I wud have liked to divide the rul file in different sections rather than one long list but ran into problems so settled for this. Any one can use this if they want to but it is based on having all these mods on in this order:

rulesets:
  - Xcom1Ruleset
  - 2012DeathSounds
  - Acid_Weaponry
  - AlienInventory
  - Batman
  - CUSTOM STATSTRINGS
  - CivArmorRich
  - CraftMissleSound
  - DartPistol
  - DartRifle
  - EleriumFlare
  - Enforcer
  - ExtraPockets
  - Extra_Explosions
  - FireStormGfx
  - FlashBangGrenades
  - GaussWeaponry
  - GenderDetail
  - GuidedMissile
  - HWP_Mortar
  - Improved_HandOb
  - Improved_Recruit_Start_Stat
  - Ironman Super Suit
  - Laser_Sniper_Rifle
  - MassAccelerator
  - PSX_Static_Cydonia_Map
  - Predator
  - SECTOPOD_HWP
  - SPACEMARINES
  - SniperRifle_custom
  - SniperRifle_u2s
  - TacticalNuke
  - UFOextender_Gun_Melee
  - ViperAssaultCannon
  - WeaponNaymore
  - WeaponTranquilizer
  - XcomUtil_Fighter_Transports
  - XcomUtil_High_Explosive_Damage
  - XcomUtil_Improved_Ground_Tanks
  - XcomUtil_Pistol_Auto_Shot
  - XcomUtil_Skyranger_Weapon_Slot
  - XcomUtil_Starting_Defensive_Improved_Base
  - YetMoreUFOTypes
  - small_rocket_small
  - Research_Alive_Aliens
  - Alternate_Lightning_Thunder
  - Commendations
  - CommendationsUFOpedia
  - Terrain_Pack_Nightly
  - ITEM LIST ORDER
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on February 22, 2015, 05:26:28 pm
Tried to improve on my earlier rul file by putting different sections in and it seemed ok when I checked it on https://yaml-online-parser.appspot.com/?url=http%3A%2F%2F but when I used the attached version it wudn't load and gave me the attached error message. Any one know what's wrong?
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: ivandogovich on February 22, 2015, 05:43:18 pm
From what I can see, your sub sections may be causing the problem.   You Probably should comment out those lines.

Yaml uses 2 spaces to indicate levels in its hierarchy, so those one space levels maybe throwing it off.

Code: [Select]
items:
# ufo components:
  - type: STR_ALIEN_ALLOYS
    listOrder: 1

etc
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on February 22, 2015, 06:22:10 pm
Tried moving the sections to 2 spaces and all individual items to 4 spaces but it comes up with an error message "invalid node"? Like I can work with the earlier big long list one but I thought it wud be handy to have sections to find items.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: ivandogovich on February 22, 2015, 06:37:39 pm
Unfortunately, that is not how the "items" sections of rulesets are formatted. 

You can break this into separate rulesets for each group if that is easier, or you can use the hash tag to comment it out.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on February 22, 2015, 06:50:04 pm
Like this?
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: SIMON BAILIE on February 22, 2015, 07:27:56 pm
Seems to work now with the # put in front of the sections, I'm no programmer or have qualifications in that respect but I'll have a read thru these 2 websites on yaml to see if I can get a grasp on basic stuff for future reference.
 https://llvm.org/docs/YamlIO.html
https://www.yaml.org/spec/1.2/spec.html#Introduction
Once again thanks for all ur help.
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: Arthanor on February 22, 2015, 08:04:02 pm
You can't do "sections" by just writing stuff in the file. Then the game comes to the line that says "ufo components" and it doesn't know what that means so it stops reading and gives an error.

Anytime you write something in the file that is not in OpenXCom-yaml ruleset syntax, you will get errors. In this case, since it is just for your ease of reading the ruleset and does nothing rules-wise, this is what we call a comment. You need to precede comments with the appropriate marker, in this case a #, and then the game will know that it's not supposed to read that. Something like:

Code: [Select]
items:
# ufo components:
  - type: STR_ALIEN_ALLOYS
    listOrder: 1
  - type: STR_ELERIUM_115
    listOrder: 2
# craft weapons:
Title: Re: minimod: Elerium and Alloys Listed on Top
Post by: Markus Ramikin on March 10, 2021, 11:46:46 pm
Added the metadata.yml necessary for OpenXCom Extended. Updated the attached file in the original post, as well as uploaded to openxcom.mod.io (https://openxcom.org/forum/index.php?topic=3302.0).

After rereading this thread I wish I'd done this from the start, if people were going to have this much trouble integrating this little thing. Oh, well.