Author Topic: [WB v1.127, SP, code] New presentations for reports (v1.2)  (Read 8821 times)

0 Members and 1 Guest are viewing this topic.

jrider

  • Regular
  • *
    • View Profile
  • Faction: Neutral
  • WB
[WB v1.127, SP, code] New presentations for reports (v1.2)
« on: August 20, 2010, 01:32:04 AM »
Here are some presentations I wrote to learn how they work (so the code it fairly commented) and to replace some of the reports menus (this is for Warband 1.127).

feel free to reuse or modify (these are v1.2), for Warband v1.127.

  • First attempt: a standalone presentation for faction relation, that extend things a bit
    Screenshot:
    (click to show/hide)
  • Second attempt: originaly planned as replacement for Known lord relations, it grew into doing Courtship and character/companions and including faction filters
    Screenshots:
    (click to show/hide)
    (click to show/hide)
    (click to show/hide)
    (click to show/hide)

Changelog:
(click to show/hide)


I also started using a method to keep the new stuff I write separate from the native source file (except when changes in these are needed), to minimize the impact when merging with other mods code.
The basic principle is to reuse the method that's used in triggers.

all you'd have to do is add an import at the beginning of the native file for the external module like (example for scripts)
(click to show/hide)

add the new contents at the end of the tuple you want it in as it's done for triggers (example for scripts)
(click to show/hide)

with the external code in a separate module (copy/paste the standard imports from it's native equivalent at the beginning so that it compiles) and declare a tuple for your own code (example as above in module_jrider_scripts.py):
(click to show/hide)

I present the code below in the traditional way to add in native's module, when a part can be externalized in the fashion described above, I'll put the External tag in the spoiler.


The first presentation is pretty straightforward, it's just display with the calculations inside the presentation itself, it handles some extra value for the Diplomacy Mod, that you can comment (or keep, there's no Diplomacy specific variables used here):

I used an extra mesh, to access to an existing resource in CommonRes, so you just need to add this to the meshes in module_meshes.py, at the end is fine :
(click to show/hide)

This goes into module_presentations.py
(click to show/hide)

and you need to hook it into the game menu inside module_game_menus.py, inside the reports find the follo:
(click to show/hide)

That's it for the first one.


continued in post #2
« Last Edit: August 21, 2010, 06:37:11 PM by jrider »

jrider

  • Regular
  • *
    • View Profile
  • Faction: Neutral
  • WB
[WB v1.127, SP, code] New presentations for reports (v1.2), part 2
« Reply #1 on: August 20, 2010, 01:35:30 AM »
The second presentation (dubbed character relations for lack of better words since it keeps growing) it a bit more involved.

It consist in a single presentation reused for 4 differents reports (character and companions being merged in one), with dynamic content (UI element created according to external sources) and moving pictures (well, picture changing according to context that is) and using external scripts to process the workload.

Note 1: the character and companions part doesn't reuse all the functionnalities of the corresponding game menus so I just add extra hook for these instead of replacing the existing menu entries.
Note 2: I haven't tested courtship with a female character, so this might not work courtship if you're playing a female.

I used two meshes provided in common resource but which have no mesh mapping in the module system, so add these at the end of module_meshes.py :
(click to show/hide)

I added some new scripts to provide and process information and dynamic creation in the presentation, add these at the end of module_scripts.py :
There 3 new scripts:
  • A common script, to create new UI element dynamically, used by each type of presentation to determine the list contents
  • Another common script, to provide information to display for character, lords and companions
  • A specific script for courtship, to return known poems to write in the main UI

since we're using some presentions items in the code, add the presentation header to the imports at the beginning of the file :
(click to show/hide)

Then add the code at the end of the scripts tuple :
(click to show/hide)


scripts continued in post #3
« Last Edit: August 21, 2010, 06:37:18 PM by jrider »

jrider

  • Regular
  • *
    • View Profile
  • Faction: Neutral
  • WB
[WB v1.127, SP, code] New presentations for reports (v1.2), part 3
« Reply #2 on: August 20, 2010, 01:36:20 AM »
(click to show/hide)


last part in post #4
« Last Edit: August 21, 2010, 06:37:24 PM by jrider »

jrider

  • Regular
  • *
    • View Profile
  • Faction: Neutral
  • WB
[WB v1.127, SP, code] New presentations for reports (v1.2), part 4
« Reply #3 on: August 20, 2010, 01:43:58 AM »
The presentation code, the load process is roughtly divided in 5 parts
  • presentation type specific initializations (title, layout, extra overlay).
  • create the commons overlays not dependent on value or which values can be changed easily (ie. text, combo button overlay).
  • populate the list and set up initial values.
  • create overlays depending on the value that need a restart of the presentation to be updated (common, then pres type specific).
(click to show/hide)

Game menu hooks to insert in module_game_menus.py, reports menu :
(click to show/hide)
(click to show/hide)
(click to show/hide)

For that second presentation I use temporary troop arrays to store data (v1.2 use temp_array_a in addition to the other 2), since I had these from Rubik's Custom Commander and didn't code them myself I forgot to add them here : that goes in module_troops.py

(click to show/hide)


and that's it.

hopefully I haven't forgotten anything, until I posted this, I hadn't realized how big it was.
« Last Edit: August 22, 2010, 10:33:36 PM by jrider »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [WB, SP, code] New presentations for reports
« Reply #4 on: August 20, 2010, 01:52:39 AM »
That looks quite cool.  I'll have to look this over in detail later.

[EDIT]A thought:  the thing we really need a better presentation for?  Trade good prices in each city.[/EDIT]
« Last Edit: August 20, 2010, 01:58:31 AM by xenoargh »

Llew

  • Cheap ass bum
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Vaegir
  • MP nick: nK_Llew
  • M&BWB
Re: [WB, SP, code] New presentations for reports
« Reply #5 on: August 20, 2010, 06:17:53 PM »
Dude, very nice! Impressive to see some really nice code like this being distributed.

I'll probably use this in the next version of Hundred Years War.

mr.master

  • Grandmaster Knight
  • *
  • A Proud Christian, A Member of Knights Of WEe, 6-1
    • View Profile
  • Faction: Neutral
  • MP nick: WEe
Re: [WB, SP, code] New presentations for reports
« Reply #6 on: August 20, 2010, 07:03:47 PM »
Awesome work jrider :P Ill surely add this to my mod (= Keep up the work : P Can't wait to see more of your scripts.  :wink:



jrider

  • Regular
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: [WB, SP, code] New presentations for reports
« Reply #7 on: August 20, 2010, 10:08:23 PM »
Awesome work jrider :P Ill surely add this to my mod (= Keep up the work : P Can't wait to see more of your scripts.  ;)

thanks :)

and as I said, these are my first presentations, which is probably why I mishandled the placement of the items in the scroll area for the second one (noticed that while doing some regression testing after adding some extra code in player/companion to display equipment).

the 1st presentation probably has the same problem but there's space enough to display the player faction in there without triggering the scroll bar anyway.

I'll update when I figure how to do it the right way ;)

GameDrifter

  • Veteran
  • *
  • Eternity is really long, especially near the end.
    • View Profile
  • Faction: Nord
Re: [WB, SP, code] New presentations for reports
« Reply #8 on: August 21, 2010, 02:43:06 AM »
Great you just added a whole new universe of stuff for me to look into putting into my mod!!!  :mrgreen:

All the same thanks for the sample, I'm already picture some fancy screens..  :wink:

Idibil

  • Grandmaster Knight
  • *
    • View Profile
    • Nova Regula
  • Faction: Nord
  • MP nick: CeltíberoIdibil
Re: [WB, SP, code] New presentations for reports
« Reply #9 on: August 21, 2010, 09:31:16 AM »
Thanks u, great work.


I have one problem only, in factions relations it load two factions of 31:



« Last Edit: August 21, 2010, 09:42:09 AM by Idibil »

sphere

  • Grandmaster Knight
  • *
    • View Profile
  • M&BWB
Re: [WB, SP, code] New presentations for reports
« Reply #10 on: August 21, 2010, 01:48:32 PM »
just to bring the discussion to the right topic from the minimap thread, noticed that you are trying to do "externalize" modded stuff as well :) Same idealogy here.  In fact, I think I'm the more extreme one here, since I want mod users to be as lazy as possible, hence the request to "wrap" some of your stuff.

I'm close to finishing my prototype "mod_options" mod kit, which is generalized version of rubik's mod options presentation in his custom commander.  Now any modding kits under the same framework can declare their own mod options like

This is a dummy option included to just switch on and off the in-game cheat mode
(click to show/hide)

and

These are mod options meant for my re-wrapping of rubik's battle minimap
(click to show/hide)

and turn it into:
(click to show/hide)

Theoretically, supports any number of properties each specified in mods, and only those active mods (under my modmerger organization) will have their mod options exposed.  And the nice thing is that the dependency is weak, so any mod kits that specifies mod_options, but the basic mod_option kit is not active, it will just be ignored (but no mod options screen)

(combo box is still untested though, so need a little more testing.... :) )

I was planning to finish this part first, then take a look at your stuff to see if it can be modularized under my current framework.  Maybe instead of replacing the existing "spartan" reports, can expose global flags to indicate to game whether to use the original reports or the new presentations (just in case some people get nostalgic....)

jrider

  • Regular
  • *
    • View Profile
  • Faction: Neutral
  • WB
Re: [WB, SP, code] New presentations for reports
« Reply #11 on: August 21, 2010, 04:05:27 PM »
Thanks u, great work.

I have one problem only, in factions relations it load two factions of 31:

my, my, that's a lot of factions  :mrgreen:

as I said earlier, it's related to the mishandling of scroll area, I fixed that one (Factions Relations presentation only for the moment) and it should display fine now .

unless coat of  arms meshes have been added for each extra faction in that mod, you might want to comment bit related to the coat of arms mesh overlay, that's the one part really designed to handle only the 6 original npcs factions (probably won't throw an error but it may display strange things starting at faction 7 (0 being player).

just to bring the discussion to the right topic from the minimap thread, noticed that you are trying to do "externalize" modded stuff as well :) Same ideology here.  In fact, I think I'm the more extreme one here, since I want mod users to be as lazy as possible, hence the request to "wrap" some of your stuff.

as a matter of fact, you did give me the idea (from the battlefield tactics kit thread) and seeing how things are done in triggers did give me the means.
I got the drive to implement it for my code after loosing a fair bit of it while merging with a new version of OSPW (thankfully I had posted most of it already, still that was almost a 1000 lines of code).

Quote
Theoretically, supports any number of properties each specified in mods, and only those active mods (under my modmerger organization) will have their mod options exposed.  And the nice thing is that the dependency is weak, so any mod kits that specifies mod_options, but the basic mod_option kit is not active, it will just be ignored (but no mod options screen)

did you think of using a scroll area to host the options (maybe with a combo button to make the options display in the scroll area mod specific) ?

Quote
I was planning to finish this part first, then take a look at your stuff to see if it can be modularized under my current framework.  Maybe instead of replacing the existing "spartan" reports, can expose global flags to indicate to game whether to use the original reports or the new presentations (just in case some people get nostalgic....)

that would be nice, since I write these for myself, I tend not to leave a choice between new/old stuff or subfeatures and let people adapt the code to their taste.

FrisianDude

  • Coitus non Awesome
  • Grandmaster Knight
  • *
  • Zis is Tshörman tärritorie!
    • View Profile
  • Faction: Neutral
  • MP nick: OLL_SirAndelot/Liudulf Ward
  • M&BWB
Re: [WB v1.127, SP, code] New presentations for reports (v1.1)
« Reply #12 on: August 21, 2010, 04:09:30 PM »
Wow, very impressive work.
Nords ruled by King Ragnar, Khergits ruled by Sanjar Khan, Rhodoks ruled by King Graveth, Swadians ruled by King Harlaus, Vaegirs ruled by King Yaroglek. All those peoples live, fight, and die in the continent of Calradia. The Nords and Rhodoks field solely infantry and archers, the Swadians and Vaegirs have infantry, archers and cavalry and the Khergit field almost exclusively cavalry. No such things as "infarty" or "calvary" exist. Play Vikingr!

leandrojas_

  • Squire
  • *
  • Hablo español...hablenme en español...
    • View Profile
  • Faction: Swadian
Re: [WB v1.127, SP, code] New presentations for reports (v1.1)
« Reply #13 on: August 21, 2010, 04:10:44 PM »
This great! :shock:

Hope you do not mind if we use in my mod. El Arte de la Guerra.

Thanks for such great work! :D
[SP, Add-on, OP, WB 1.134, ] Towers, walls and ladders. V1.5.2:
http://forums.taleworlds.com/index.php?topic=132920.msg3202250#msg3202250

[SP - Add on - MAP]Mundus Magnus http://forums.taleworlds.com/index.php/topic,243233.0.html


Idibil

  • Grandmaster Knight
  • *
    • View Profile
    • Nova Regula
  • Faction: Nord
  • MP nick: CeltíberoIdibil
Re: [WB v1.127, SP, code] New presentations for reports (v1.1)
« Reply #14 on: August 21, 2010, 04:22:21 PM »
@jrider

Quote
my, my, that's a lot of factions  :mrgreen:

as I said earlier, it's related to the mishandling of scroll area, I fixed that one (Factions Relations presentation only for the moment) and it should display fine now .

unless coat of  arms meshes have been added for each extra faction in that mod, you might want to comment bit related to the coat of arms mesh overlay, that's the one part really designed to handle only the 6 original npcs factions (probably won't throw an error but it may display strange things starting at faction 7 (0 being player).

Thanks! It work perfectly now  :D