wiremod / wire

Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.
http://www.wiremod.com
Apache License 2.0
550 stars 332 forks source link

Request - Possibility add custom fonts to EGP.ValidFonts #1045

Closed AlexALX closed 8 years ago

AlexALX commented 8 years ago

Hello, not sure if i'm writting it right section, and sorry for my english.

I'm one of developers of stargate carter addon pack and we have several stargate-related fonts (glyphs) what used in our wiremod e2 screens etc. By default wiremod egp allow only fonts what stored in EGP.ValidFonts variable inside wire\lua\entities\gmod_wire_egp\lib\egplib\materials.lua file. This makes impossible without manual editing of this file add custom fonts. Much of our users constantly report about "bug" that fonts not displayed and we always answer that they should edit this file manually, but not all actually can do this (if use workshop version for example).

So is this possible to add some feature so we can use it to add our fonts in EGP.ValidFonts variable in e2 library without edition file? This could help us very much. E2 advanced already have this feature using this code in library:

local RenderCom = EXPADV.GetComponent("render") if RenderCom and RenderCom.ValidFonts then .... table.Merge(RenderCom.ValidFonts,CapFonts)

Thank you for attention.

Divran commented 8 years ago

I believe you can just edit EGP.ValidFonts in a different file, similar to what you did with the code in your post there. As long as you add fonts in the same order on both the server and the client.

Speaking of stargate CAP, have you fixed this bug yet: https://facepunch.com/showthread.php?t=950900&p=25423015&viewfull=1#post25423015 It'll probably be a pain to fix because last time I checked, whoever made most of the weapons in CAP was stupid and copy pasted the very function I fixed in that post, so you'll have to make all weapons use the same function first.

AlexALX commented 8 years ago

Ow ok, probably i can try make some file in lua/entities/gmod_wire_egp/lib/egplib/ for add fonts to egp after materials file loaded (but will need copy-paste some code), thanks for idea, i'll try.

As for link and code what you give - i'll also check it later, but no, this wasn't fixed/changed.

Divran commented 8 years ago

what no, you don't need to modify egp, you can just modify the table EGP.ValidFonts from any file

AlexALX commented 8 years ago

Ok, didn't really checked that EGP is global variable not local like I thought for some reason...

I tried add to this table needed fonts (at both sides - client and server) in wire stargate library, it seems like fonts added to table (PrintTable confirms this at both sides), but EGP itself still don't apply those fonts and display default one. So something still wrong or missing. I also tried copy-paste EGP.ValidFonts_Lookup code from materials.lua but still not changes.

AlexALX commented 8 years ago

I think i god why it don't work. If compare validfonts at client and server, then it not match.

Server: (table) 0x2e01dd48 { (number) 1 => (string) 'WireGPU_ConsoleFont' (number) 2 => (string) 'Coolvetica' (number) 3 => (string) 'Arial' (number) 4 => (string) 'Lucida Console' (number) 5 => (string) 'Trebuchet' (number) 6 => (string) 'Courier New' (number) 7 => (string) 'Times New Roman' (number) 8 => (string) 'ChatFont' (number) 9 => (string) 'Marlett' (number) 10 => (string) 'Roboto' (number) 11 => (string) 'Stargate Address Glyphs SG1' (number) 12 => (string) 'Stargate Address Glyphs Concept' (number) 13 => (string) 'Stargate Address Glyphs U' (number) 14 => (string) 'Stargate Address Glyphs Atl' (number) 15 => (string) 'Anquietas' (number) 16 => (string) 'Quiver' }

Client: (table) 0x3469eb68 { (number) 1 => (string) 'WireGPU_ConsoleFont' (number) 2 => (string) 'Coolvetica' (number) 3 => (string) 'Arial' (number) 4 => (string) 'Lucida Console' (number) 5 => (string) 'Trebuchet' (number) 6 => (string) 'Courier New' (number) 7 => (string) 'Times New Roman' (number) 8 => (string) 'ChatFont' (number) 9 => (string) 'Marlett' (number) 10 => (string) 'Roboto' (number) 11 => (string) 'WireEGP_18_1' (number) 12 => (string) 'WireEGP_18_2' (number) 13 => (string) 'WireEGP_18_3' (number) 14 => (string) 'WireEGP_18_4' (number) 15 => (string) 'WireEGP_18_5' (number) 16 => (string) 'WireEGP_18_6' (number) 17 => (string) 'WireEGP_18_7' (number) 18 => (string) 'WireEGP_18_8' (number) 19 => (string) 'WireEGP_18_9' (number) 20 => (string) 'WireEGP_18_10' (number) 21 => (string) 'Stargate Address Glyphs SG1' (number) 22 => (string) 'Stargate Address Glyphs Concept' (number) 23 => (string) 'Stargate Address Glyphs U' (number) 24 => (string) 'Stargate Address Glyphs Atl' (number) 25 => (string) 'Anquietas' (number) 26 => (string) 'Quiver' }

So like you can see fontid isn't match real font... There need somehow to add fonts before materials.lua run its loop for adding fonts, but after it created EGP.ValidFonts with default fonts. So there is problem and i probably can't fix this.

AlexALX commented 8 years ago

Oh sorry for my stupidly, probably i found solution, just recreate whole table client-side with setting correct order. Going to try...

EDIT: YES! It worked. Thank you for help, now i can go to sleep))

Divran commented 8 years ago

alternatively you can simply do this

table.insert( EGP.ValidFonts, 11, "Stargate Address Glyphs SG1" )
table.insert( EGP.ValidFonts, 12, "Stargate Address Glyphs Concept" )
table.insert( EGP.ValidFonts, 13, "Stargate Address Glyphs U" )
... and so on

to insert them at the correct place

AlexALX commented 8 years ago

Hmm, in this case probably better add it to start of table, because if you or someone in wiremod will add some new font (like was with "Roboto") so not break order because of this client-side. Thank you again anyway.

EDIT: hmmm, forgot again about fontids in "WireEGP_18_1", so yes, it can be added only after or again need recreate table... Probably i'll left my previous code for recreate)