Author Topic: ScreenWidth & ScreenHeight return screen size, but not window size  (Read 2399 times)

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
I created a github issue here about the subject. I would like to have a responsive theme, but can not do so without a way of getting the attract mode window size instead of the screen size. I could possibly read and parse window.am, but the file is not updated when switching to fill screen mode. I could parse attract.cfg and get the window_mode attribute to solve this. Is there an easier way that I am missing?

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: ScreenWidth & ScreenHeight return screen size, but not window size
« Reply #1 on: April 15, 2017, 06:29:22 PM »
So, I created a function that cab parse attract.cfg and window.am. To have it update upon resizing the window, a tick function would have to be created. Am I going about this the correct way? Should I do something differently? Does it even matter? Here is what I have so far.

Code: [Select]
// Preliminary Support for isWindowWidescreen
fe.load_module("file-format");
function isWindowWidescreen() {
local windowMode = "";
local attractConfigFile = txt.loadFile(FeConfigDirectory + "/attract.cfg");
foreach(line in attractConfigFile.lines){
local isLine = line.find("window_mode");
if (isLine != null) windowMode = strip(line.slice(12));
}
if (windowMode == "window" || "window_no_border") {
local windowSize = "";
local attractWindowFile = txt.loadFile(FeConfigDirectory + "/window.am");
foreach(line in attractWindowFile.lines){
local isLine = line.find("size");
if (isLine != null) windowSize = strip(line.slice(4));
}
return splitRes(windowSize, "width", ",").tofloat() / splitRes(windowSize, "height", ",").tofloat() > 4.0 / 3.0;
}
else {
return fe.layout.width.tofloat() / fe.layout.height.tofloat() > 4.0 / 3.0;
}
}