1
- using System . IO ;
2
- using ImGuiNET ;
3
- using Silk . NET . Maths ;
4
- using Silk . NET . OpenGL . Extensions . ImGui ;
5
- using Silk . NET . Windowing ;
6
- using SixLabors . ImageSharp ;
7
- using SixLabors . ImageSharp . PixelFormats ;
8
1
using Volte . Commands . Text . Modules ;
9
- using Volte . UI ;
10
- using Image = SixLabors . ImageSharp . Image ;
11
2
12
3
namespace Volte ;
13
4
14
5
public class VolteBot
15
6
{
16
7
public static Task StartAsync ( )
17
8
{
18
- Console . Title = DefaultWindowOptions . Title ;
9
+ Console . Title = $ "Volte { Version . InformationVersion } " ;
19
10
Console . CursorVisible = false ;
20
11
return new VolteBot ( ) . LoginAsync ( ) ;
21
12
}
@@ -39,9 +30,6 @@ private async Task LoginAsync()
39
30
40
31
ServiceProvider = new ServiceCollection ( ) . AddAllServices ( ) . BuildServiceProvider ( ) ;
41
32
42
- if ( Program . CommandLineArguments . TryGetValue ( "ui" , out var sizeStr ) )
43
- CreateUi ( sizeStr ) ;
44
-
45
33
_client = ServiceProvider . Get < DiscordSocketClient > ( ) ;
46
34
_cts = ServiceProvider . Get < CancellationTokenSource > ( ) ;
47
35
@@ -96,64 +84,4 @@ public static async Task ShutdownAsync(DiscordSocketClient client, ServiceProvid
96
84
97
85
Environment . Exit ( 0 ) ;
98
86
}
99
-
100
- // WindowOptions.Default with custom title and larger base window
101
- public static readonly WindowOptions DefaultWindowOptions = new (
102
- isVisible : true ,
103
- position : new Vector2D < int > ( 50 , 50 ) ,
104
- size : new Vector2D < int > ( 1600 , 900 ) ,
105
- framesPerSecond : 0 ,
106
- updatesPerSecond : 0.0 ,
107
- api : GraphicsAPI . Default ,
108
- title : $ "Volte { Version . InformationVersion } ",
109
- windowState : WindowState . Normal ,
110
- windowBorder : WindowBorder . Resizable ,
111
- isVSync : true ,
112
- shouldSwapAutomatically : true ,
113
- videoMode : VideoMode . Default
114
- ) ;
115
-
116
- private static void CreateUi ( string sizeStr )
117
- {
118
- var uiParams = GetUiParams ( sizeStr . TryParse < int > ( out var fsz ) ? fsz : 17 ) ;
119
-
120
- if ( UiManager . TryCreateUi ( uiParams , out var uiStartError ) )
121
- {
122
- UiManager . AddView ( new VolteUiView ( ) ) ;
123
- UiManager . StartThread ( "Volte UI Thread" ) ;
124
- }
125
- else Error ( LogSource . UI , $ "Could not create UI: { uiStartError ! . Message } ") ;
126
- }
127
-
128
- private static readonly string [ ] UiFontResourceKeys = [ "Regular" , "Bold" , "BoldItalic" , "Italic" ] ;
129
-
130
- public static UiManager . CreateParams GetUiParams ( int fontSize )
131
- {
132
- unsafe
133
- {
134
- return new UiManager . CreateParams
135
- {
136
- WindowIcon = loadIcon ( ) ,
137
- WOptions = DefaultWindowOptions ,
138
- Theme = Spectrum . Dark ,
139
- OnConfigureIo = _ =>
140
- {
141
- UiFontResourceKeys . ForEach ( key =>
142
- {
143
- using var embeddedFont = Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( key ) ;
144
- if ( embeddedFont != null )
145
- UiManager . LoadFontFromStream ( embeddedFont , key , fontSize ) ;
146
- } ) ;
147
- }
148
- } ;
149
- }
150
-
151
- Image < Rgba32 > loadIcon ( )
152
- {
153
- using var iconStream = Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( "VolteIcon" ) ;
154
- return iconStream == null
155
- ? null
156
- : Image . Load < Rgba32 > ( iconStream ) ;
157
- }
158
- }
159
87
}
0 commit comments