This commit is contained in:
RealFD 2022-03-04 11:16:27 +01:00
parent 76477b5cf3
commit 7de41e16e1
1 changed files with 52 additions and 79 deletions

View File

@ -3,6 +3,9 @@ json = require "json"
local common = require('common.common');
local difbar = require("components.diff_rectangle");
local Background = require('components.background');
local Dim = require("common.dimensions")
local Wallpaper = require("components.wallpaper")
local msg = game.GetSkinSetting("MSG");
local normname = game.GetSkinSetting("username")
@ -95,26 +98,6 @@ local missing_song = false;
local placeholderJacket = gfx.CreateSkinImage("song_select/loading.png", 0)
local did_exit = false;
-- Window variables
local resX, resY
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX, fullY
local desw = 1080
local desh = 1920
local function resolutionChange(x, y)
resX = x
resY = y
fullX = portraitWidescreenRatio * y
fullY = y
end
local irHeartbeatRequested = false;
local irText = ''
@ -169,22 +152,17 @@ local drawIdol = function(deltaTime)
idolAnimTransitionScale = 1;
end
gfx.ImageRect(0, 0, resX,resY, idolAnimation, 1, 0);
gfx.ImageRect(0, 0, resx,resy, idolAnimation, 1, 0);
gfx.GlobalAlpha(1);
end
end
songjacket = function() -- self explanatory -- done
local resx, resy = game.GetResolution()
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
local jw , jh = gfx.ImageSize(m_jacket);
gfx.BeginPath();
-- gfx.ImageRect(jacketPanelX, jacketPanelY, jw/1.18, jh/1.18, m_jacket,1,0);
gfx.ImageRect(resX, resY, jw/1.18, jh/1.18, m_jacket,1,0);
gfx.ImageRect(jacketPanelX, jacketPanelY, jw/1.18, jh/1.18, m_jacket,1,0);
gfx.BeginPath()
gfx.ImageRect(jacketPanelX+12, jacketPanelY+19,jw/1.269,jh/1.35,jacket,1,0)
@ -459,7 +437,7 @@ mouse_clipped = function(x,y,w,h)
end;
draw_room = function(name, x, y, selected, hoverindex)
local buttonWidth = resX*(3/4);
local buttonWidth = resx*(3/4);
local rx = x - (buttonWidth / 2);
local ty = y - (buttonHeight / 2);
local roomButtonBorder = buttonBorder;
@ -584,17 +562,17 @@ function render_loading()
gfx.Save()
gfx.ResetTransform()
gfx.BeginPath()
gfx.MoveTo(resX, resY)
gfx.LineTo(resX - 350, resY)
gfx.LineTo(resX - 300, resY - 50)
gfx.LineTo(resX, resY - 50)
gfx.MoveTo(resx, resy)
gfx.LineTo(resx - 350, resy)
gfx.LineTo(resx - 300, resy - 50)
gfx.LineTo(resx, resy - 50)
gfx.ClosePath()
gfx.FillColor(33,33,33)
gfx.Fill()
gfx.FillColor(255,255,255)
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT, gfx.TEXT_ALIGN_BOTTOM)
gfx.FontSize(70)
gfx.Text("LOADING...", resX - 20, resY - 3)
gfx.Text("LOADING...", resx - 20, resy - 3)
gfx.Restore()
end
@ -696,7 +674,7 @@ function draw_rooms(y, h)
if room.password then
status = status..' <P>'
end
draw_room(room.name .. ': '.. status, resX / 2, ypos, i == selected_room_index, function()
draw_room(room.name .. ': '.. status, resx / 2, ypos, i == selected_room_index, function()
join_room(room)
end)
end
@ -710,7 +688,7 @@ change_selected_room = function(off)
return;
end
local h = resY - 290;
local h = resy - 290;
local num_rooms_visible = math.floor(h / (buttonHeight + 10))
@ -745,18 +723,13 @@ end
function render_lobby(deltaTime)
local resx, resy = game.GetResolution()
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
local jw , jh = gfx.ImageSize(bg);
gfx.BeginPath();
gfx.ImageRect(0, 0, resX, resY, bg,1,0);
gfx.ImageRect(0, 0, resx, resy, bg,1,0);
drawIdol(deltaTime)
gfx.BeginPath();
gfx.ImageRect(0, 0, resX, resY, bg_graid1,1,0);
gfx.ImageRect(0, 0, resX, resY, bg_graid2,1,0);
gfx.ImageRect(0, 0, resx, resy, bg_graid1,1,0);
gfx.ImageRect(0, 0, resx, resy, bg_graid2,1,0);
drawHeader()
gfx.BeginPath();
m_base_part()
@ -788,29 +761,29 @@ end
function render_room_list(deltaTime)
draw_rooms(175, resY - 290);
draw_rooms(175, resy - 290);
-- Draw cover for rooms out of view
gfx.BeginPath()
gfx.FillColor(20, 20, 20)
gfx.Rect(0, 0, resX, 145)
gfx.Rect(0, resY-170, resX, 170)
gfx.Rect(0, 0, resx, 145)
gfx.Rect(0, resy-170, resx, 170)
gfx.Fill()
gfx.BeginPath()
gfx.FillColor(60, 60, 60)
gfx.Rect(0, 145, resX, 2)
gfx.Rect(0, resY-170-2, resX, 2)
gfx.Rect(0, 145, resx, 2)
gfx.Rect(0, resy-170-2, resx, 2)
gfx.Fill()
gfx.FillColor(255,255,255)
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER, gfx.TEXT_ALIGN_BOTTOM)
gfx.FontSize(70)
gfx.Text("Multiplayer Rooms", resX/2, 100)
gfx.Text("Multiplayer Rooms", resx/2, 100)
if not loading then
draw_button("Create new room", resX/2, resY-40-buttonHeight, resX*(3/4), new_room);
draw_button("Create new room", resx/2, resy-40-buttonHeight, resx*(3/4), new_room);
end
end
@ -820,40 +793,40 @@ function render_password_screen(deltaTime)
gfx.FillColor(255,255,255)
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER, gfx.TEXT_ALIGN_BOTTOM)
gfx.FontSize(70)
gfx.Text("Joining "..selected_room.name.."...", resX/2, resY/4)
gfx.Text("Joining "..selected_room.name.."...", resx/2, resy/4)
gfx.FillColor(50,50,50)
gfx.BeginPath()
gfx.Rect(0, resY/2-10, resX, 40)
gfx.Rect(0, resy/2-10, resx, 40)
gfx.Fill();
gfx.FillColor(255,255,255)
gfx.Text("Please enter room password:", resX/2, resY/2-40)
gfx.Text(string.rep("*",#textInput.text), resX/2, resY/2+40)
gfx.Text("Please enter room password:", resx/2, resy/2-40)
gfx.Text(string.rep("*",#textInput.text), resx/2, resy/2+40)
if passwordError then
gfx.FillColor(255,50,50)
gfx.FontSize(60 + math.floor(passwordErrorOffset*20))
gfx.Text("Invalid password", resX/2, resY/2+80)
gfx.Text("Invalid password", resx/2, resy/2+80)
end
draw_button("Join", resX/2, resY*3/4, resX/2, mpScreen.JoinWithPassword);
draw_button("Join", resx/2, resy*3/4, resx/2, mpScreen.JoinWithPassword);
end
function render_new_room_password(delta_time)
gfx.FillColor(255,255,255)
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER, gfx.TEXT_ALIGN_BOTTOM)
gfx.FontSize(70)
gfx.Text("Create New Room", resX/2, resY/4)
gfx.Text("Create New Room", resx/2, resy/4)
gfx.FillColor(50,50,50)
gfx.BeginPath()
gfx.Rect(0, resY/2-10, resX, 40)
gfx.Rect(0, resy/2-10, resx, 40)
gfx.Fill();
gfx.FillColor(255,255,255)
gfx.Text("Enter room password:", resX/2, resY/2-40)
gfx.Text(string.rep("*",#textInput.text), resX/2, resY/2+40)
draw_button("Create Room", resX/2, resY*3/4, resX/2, mpScreen.NewRoomStep);
gfx.Text("Enter room password:", resx/2, resy/2-40)
gfx.Text(string.rep("*",#textInput.text), resx/2, resy/2+40)
draw_button("Create Room", resx/2, resy*3/4, resx/2, mpScreen.NewRoomStep);
end
--here
function render_new_room_name(deltaTime)
@ -862,31 +835,31 @@ function render_new_room_name(deltaTime)
gfx.FillColor(255,255,255)
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER, gfx.TEXT_ALIGN_BOTTOM)
gfx.FontSize(70)
gfx.Text("Create New Room", resX/2, resY/4)
gfx.Text("Create New Room", resx/2, resy/4)
gfx.Rect(0, resY/2-10, resX, 60)
gfx.Rect(0, resy/2-10, resx, 60)
gfx.Text("Please enter room name:", resX/2, resY/2-40)
gfx.Text(textInput.text, resX/2, resY/2+40)
draw_button("Next", resX/2, resY*3/4, resX/2, mpScreen.NewRoomStep);
gfx.Text("Please enter room name:", resx/2, resy/2-40)
gfx.Text(textInput.text, resx/2, resy/2+40)
draw_button("Next", resx/2, resy*3/4, resx/2, mpScreen.NewRoomStep);
end
function render_set_username(deltaTime)
gfx.FillColor(255,255,255)
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER, gfx.TEXT_ALIGN_BOTTOM)
gfx.FontSize(70)
gfx.Text("First things first...", resX/2, resY/4)
gfx.Text("First things first...", resx/2, resy/4)
gfx.FillColor(50,50,50)
gfx.BeginPath()
gfx.Rect(0, resY/2-10, resX, 60)
gfx.Rect(0, resy/2-10, resx, 60)
gfx.Fill();
gfx.FillColor(255,255,255)
gfx.Text("Enter a display name:", resX/2, resY/2-40)
gfx.Text(textInput.text, resX/2, resY/2+40)
draw_button("Join Multiplayer", resX/2, resY*3/4, resX/2, function()
gfx.Text("Enter a display name:", resx/2, resy/2-40)
gfx.Text(textInput.text, resx/2, resy/2+40)
draw_button("Join Multiplayer", resx/2, resy*3/4, resx/2, function()
loading = true;
mpScreen.SaveUsername()
end);
@ -894,14 +867,14 @@ function render_set_username(deltaTime)
end
render = function(deltaTime)
local resx, resy = game.GetResolution()
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
buttonWidth = resX*(3/4);
Dim.updateResolution()
game.Log(Dim.view.width,game.LOGGER_ERROR)
Wallpaper.render()
Dim.transformToDesignSpace()
buttonWidth = resx*(3/4);
mposx,mposy = game.GetMousePos();
common.stopMusic();