-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWBP_Option.lua
142 lines (128 loc) · 4.78 KB
/
WBP_Option.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
--
-- DESCRIPTION
--
-- @COMPANY **
-- @AUTHOR **
-- @DATE ${date} ${time}
--
---@type WBP_Option_C
local M = UnLua.Class()
--function M:Initialize(Initializer)
--end
--function M:PreConstruct(IsDesignTime)
--end
function M:de_windowmode()
self.windowmode_int = UE.UKismetMathLibrary.Conv_ByteToInt(self.windowmode)
self.windowmode = UE.UKismetMathLibrary.Conv_IntToByte(UE.UKismetMathLibrary.Clamp(self.windowmode_int - 1 , 0, 2))
end
function M:in_windowmode()
self.windowmode_int = UE.UKismetMathLibrary.Conv_ByteToInt(self.windowmode)
self.windowmode = UE.UKismetMathLibrary.Conv_IntToByte(UE.UKismetMathLibrary.Clamp(self.windowmode_int + 1 , 0, 2))
end
function M:de_resolution()
self.ResolutionIndex = UE.UKismetMathLibrary.Clamp(self.ResolutionIndex - 1, 0, 4)
if self.ResolutionIndex == 0 then
self.Resolution.X = 1280
self.Resolution.Y = 720
elseif self.ResolutionIndex == 1 then
self.Resolution.X = 1600
self.Resolution.Y = 900
elseif self.ResolutionIndex == 2 then
self.Resolution.X = 1920
self.Resolution.Y = 1080
elseif self.ResolutionIndex == 3 then
self.Resolution.X = 2560
self.Resolution.Y = 1440
elseif self.ResolutionIndex == 4 then
self.Resolution.X = 3840
self.Resolution.Y = 2160
end
end
function M:in_resolution()
self.ResolutionIndex = UE.UKismetMathLibrary.Clamp(self.ResolutionIndex + 1, 0, 4)
if self.ResolutionIndex == 0 then
self.Resolution.X = 1280
self.Resolution.Y = 720
elseif self.ResolutionIndex == 1 then
self.Resolution.X = 1600
self.Resolution.Y = 900
elseif self.ResolutionIndex == 2 then
self.Resolution.X = 1920
self.Resolution.Y = 1080
elseif self.ResolutionIndex == 3 then
self.Resolution.X = 2560
self.Resolution.Y = 1440
elseif self.ResolutionIndex == 4 then
self.Resolution.X = 3840
self.Resolution.Y = 2160
end
end
function M:in_graphic()
self.GraphicsIndex = UE.UKismetMathLibrary.Clamp(self.GraphicsIndex + 1, 0, 4)
end
function M:de_graphic()
self.GraphicsIndex = UE.UKismetMathLibrary.Clamp(self.GraphicsIndex - 1, 0, 4)
end
function M:SetVsync()
self.Vsync = not self.Vsync
end
function M:Apply()
self.usersetting:SetFullscreenMode(self.windowmode)
self.usersetting:SetOverallScalabilityLevel(self.GraphicsIndex)
self.usersetting:SetVSyncEnabled(self.Vsync)
self.usersetting:SetScreenResolution(self.Resolution)
self.usersetting:ApplySettings(true)
self:SetVisibility(UE.ESlateVisibility.Collapsed)
if UE.UGameplayStatics.GetCurrentLevelName(self:GetWorld(),true) == "DefaultLevel" then
local __widgets = UE.TArray(UE.UUserWidget)
UE.UWidgetBlueprintLibrary.GetAllWidgetsOfClass(
self:GetWorld(),
__widgets,
UE.UClass.Load("/Game/TestFile/UserWidget/WBP_UI.WBP_UI_C"),
false
)
self.WBP_UI = __widgets:GetRef(1)
self.WBP_UI:SetVisibility(UE.ESlateVisibility.Visible)
else
local __widgets = UE.TArray(UE.UUserWidget)
UE.UWidgetBlueprintLibrary.GetAllWidgetsOfClass(
self:GetWorld(),
__widgets,
UE.UClass.Load("/Game/TestFile/UserWidget/WBP_PauseMenu.WBP_PauseMenu_C"),
false
)
self.WBP_Pasumenu = __widgets:GetRef(1)
self.WBP_Pasumenu:SetVisibility(UE.ESlateVisibility.Visible)
end
end
function M:Construct()
self.usersetting = UE.UGameUserSettings.GetGameUserSettings()
self.usersetting:LoadSettings(false)
self.WindowMode = self.usersetting:GetFullscreenMode()
self.GraphicsIndex = self.usersetting:GetOverallScalabilityLevel()
self.Vsync = self.usersetting:IsVSyncEnabled()
self.Resolution = self.usersetting:GetScreenResolution()
if self.Resolution.X == 1280 then
self.ResolutionIndex = 0
elseif self.Resolution.X == 1600 then
self.ResolutionIndex = 1
elseif self.Resolution.X == 1920 then
self.ResolutionIndex = 2
elseif self.Resolution.X == 2560 then
self.ResolutionIndex = 3
elseif self.Resolution.X == 3840 then
self.ResolutionIndex = 4
end
self.de_windowmode_button.OnClicked:Add(self,self.de_windowmode)
self.in_windowmode_button.OnClicked:Add(self,self.in_windowmode)
self.In_Resolution_Button.OnClicked:Add(self,self.in_resolution)
self.De_Resolution_Button.OnClicked:Add(self,self.de_resolution)
self.De_Graphics_Button.OnClicked:Add(self,self.de_graphic)
self.In_Graphics_Button.OnClicked:Add(self,self.in_graphic)
self.De_Vsync_Button.OnClicked:Add(self,self.SetVsync)
self.In_Vsync_Button.OnClicked:Add(self,self.SetVsync)
self.Apply_Button.OnClicked:Add(self,self.Apply)
end
--function M:Tick(MyGeometry, InDeltaTime)
--end
return M