Here's what I've already tried.
I tried putting this code:
<css><![CDATA[
<style>
</style>
]]></css>
into the game
object, and putting JS.addText (game.css)
into the start script.
This doesn't allow me to edit the map background, or any other element that has an inline style=""
attribute within the HTML.
I also tried putting THIS code:
<object name="interface_obj">
<cssOverride><![CDATA[
<style>
</style>
]]></cssOverride>
</object>
into the game
object, then putting JS.addText (interface_obj.cssOverride)
into my inituserinterface
script (I followed these instructions on overriding InitUserInterface
.
This still doesn't let me edit ALL elements, only some of them, like #txtCommand
or #status
. The others had no effect. Pesky inline style attributes!!
I even tried following Quest's documentation tutorial on customizing the UI, but I don't like how tedious it is. I also failed to edit those pesky aforementioned elements.
Lastly, I tried putting AddExternalStylesheet(GetFileURL("Stylesheet.css"))
AND AddStylesheet(GetFileURL("Stylesheet.css"))
(on separate occasions) while having Stylesheet.css
in my game's main folder.
My Stylesheet.css
is the EXACT same CSS that I used in my other attempts above, but they don't work. However, when I try to save Stylesheet.css
while the game is running, it says I don't have permission. So it's reading the file, but not... using it...? What the hell am I missing?!
I link an external stylesheet to my game and have any element, ID, or class respond to that CSS. I'm able to change the grid map's background, customize the panels completely, or even make the game look like an outdated government website if I wanted to.
I have full control, just like I do with any old HTML file on my hard drive, and I can just look up elements with HTML tools.
Some of them say they got it to work, but I just can't get mine working, for some reason. I even tried downloading that one stylesheet library that's supposed to extract the CSS and let you edit it, but I guess it's built for the newest version of Quest, which crashes upon loading any file. Even when making a new game.
Failed to load game due to the following errors:
* Error: Error adding type 'cssextern' to element 'game': No element 'cssextern' of type 'ObjectType'
Anyone know how to fix this?
, but I guess it's built for the newest version of Quest, which crashes upon loading any file. Even when making a new game.
I'm still on Q 5.7.w and I'm using that lib.
Why it crashes your game.... I honestly have no idea. If you do manage to get it to work though there's a big window on that tab where you can just paste all your CSS in.
This doesn't allow me to edit the map background, or any other element that has an inline
style=""
attribute within the HTML
Inline style attributes override stylesheets.
If you want to override the inline style attribute, you need to change the inline style.
Like this:
JS.eval("$('#elementId').css('background-color', 'green');")
That will modify one CSS property of the specified element or class, leaving all others as they are. Note that this finds all currently-existing elements which match the selector'#elementId'
, and adds style="color: green"
to them (as well as removing any 'color' properties from any existing style=""
attributes). Therefore it will not affect an element which is created after the script is run.
You should also be able to use the CSS !important
declaration.
For example:
#txtCommand {
color: red !important;
}
This tells the browser that this rule cannot be overruled by a style=""
attribute.
Holy shit, thank you!
That is exactly what I needed! You're a life saver.