Hard Light Productions Forums
Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: SeeNeYe on August 08, 2010, 10:27:32 am
-
Hi all,
I've managed to write a script for the preload picture which permit to prevent it to stretch across the screen and display it on the screen's center whatever the screen's resolution.
#Global hooks
$Splash: [
x = (gr.getScreenWidth()-800)/2
y = (gr.getScreenHeight()-600)/2
gr.drawImage("PreLoad.dds", x, y)
]
+Override: true
#End
This code allows to have a correct aspect ratio even on 16/10 and triple head displays. :D
Now, I would like to extend this concept to the entire FS2O User Interface.
I guess that I could start from the "On Game Init" hook but for the rest i'm a bit newbie in the LUA scripting, so if anybody has some ideas on how I can manage to do it, it would be great ! :)
Thx (c)
-
Except that you're really doing it wrong :P
Instead of using
x = (gr.getScreenWidth()-800/2)
You should do it like this:
#Global hooks
$Splash: [
screenX = gr.getScreenWidth()
screenY = gr.getScreenHeight()
if screenX >= 1024 then
image = gr.loadTexture("2_preload.dds")
else
image = gr.loadTexture("preload.dds")
end
if texture:isValid() then
x = (screenX - image:getWidth())/2
y = (screenY - image:getHeight())/2
gr.drawImage(image, x, y)
end
]
+Override: true
#End
EDIT: Oops, slight oversight.
-
:)
you're completly right, as there should be a compatibility with resolutions lower than 1024 wide, as in the original game, but my script is not perfect at all ^^
Any idea to do the same thing with all the UI display ? :P
-
Yes.
However, I should warn you that it's impossible.
-
wow really impossible ?
I guessed that was not an easy task, but not this much !
thx for your answer btw
-
Hmm, I would love the interface sticking to 4:3 resolution. Finally getting rid of the stretching on widescreen resolutions.
-
:D Definitly !
-
Hmm, I would love the interface sticking to 4:3 resolution. Finally getting rid of the stretching on widescreen resolutions.
Yes, but that's something that has to be fixed on the code side, really. A rewrite, similar to the HUD rewrite effort, basically.
-
hi
:( the new script is not working, i've got this error from the debugger :
LUA ERROR: [string "Splash"]:9: attempt to index global 'texture' (a nil value)
------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name: (null)
Name of:
Function type: main
Defined on: 0
Upvalues: 0
Source: Splash
Short source: [string "Splash"]
Current line: 4
- Function line: 0
------------------------------------------------------------------
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
------------------------------------------------------------------
I've checked and re-checked everything, but it seems not working at all.
Any clue ? thx :)
EDIT: problem resolved, i'm feeling really newbie lol
#Global hooks
$Splash: [
screenX = gr.getScreenWidth()
screenY = gr.getScreenHeight()
if screenX >= 1024 then
image = gr.loadTexture("2_preload.dds")
else
image = gr.loadTexture("preload.dds")
end
if texture:isValid() then => in this line it's not the right variable name, it should be image :)
x = (screenX - image:getWidth())/2
y = (screenY - image:getHeight())/2
gr.drawImage(image, x, y)
end
]
+Override: true
#End
-
Actually, the error is mine. But good spotting nonetheless.
-
That'ts a good start anyway, i now have a non stretched splash screen on my triplehead setup :D
-
Hmm, I would love the interface sticking to 4:3 resolution. Finally getting rid of the stretching on widescreen resolutions.
Yes, but that's something that has to be fixed on the code side, really. A rewrite, similar to the HUD rewrite effort, basically.
For those who are not aware, there's already been significant progress on the new HUD code. See http://www.hard-light.net/forums/index.php?topic=69858.0
-
E doesn't recommend using it for now unless you know what you're doing with it, and I don't think a lot of us do.
-
Once it goes into antipodes, that's when you should take another look at it.