mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
More code commenting and cleanup.
This commit is contained in:
parent
c81014d6ef
commit
e83957c685
@ -187,8 +187,8 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyDown( Key key ) {
|
public override bool HandlesKeyDown( Key key ) {
|
||||||
if( key == game.Mapping( KeyMapping.PauseOrExit ) ||
|
if( key == game.Mapping( KeyBinding.PauseOrExit ) ||
|
||||||
key == game.Mapping( KeyMapping.OpenInventory ) ) {
|
key == game.Mapping( KeyBinding.OpenInventory ) ) {
|
||||||
game.SetNewScreen( new NormalScreen( game ) );
|
game.SetNewScreen( new NormalScreen( game ) );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -216,15 +216,15 @@ namespace ClassicalSharp {
|
|||||||
suppressNextPress = false;
|
suppressNextPress = false;
|
||||||
|
|
||||||
if( HandlesAllInput ) { // text input bar
|
if( HandlesAllInput ) { // text input bar
|
||||||
if( key == game.Mapping( KeyMapping.SendChat )
|
if( key == game.Mapping( KeyBinding.SendChat )
|
||||||
|| key == game.Mapping( KeyMapping.PauseOrExit ) ) {
|
|| key == game.Mapping( KeyBinding.PauseOrExit ) ) {
|
||||||
HandlesAllInput = false;
|
HandlesAllInput = false;
|
||||||
if( game.CursorVisible )
|
if( game.CursorVisible )
|
||||||
game.CursorVisible = false;
|
game.CursorVisible = false;
|
||||||
game.Camera.RegrabMouse();
|
game.Camera.RegrabMouse();
|
||||||
game.Keyboard.KeyRepeat = false;
|
game.Keyboard.KeyRepeat = false;
|
||||||
|
|
||||||
if( key == game.Mapping( KeyMapping.PauseOrExit ) )
|
if( key == game.Mapping( KeyBinding.PauseOrExit ) )
|
||||||
textInput.Clear();
|
textInput.Clear();
|
||||||
textInput.SendTextInBufferAndReset();
|
textInput.SendTextInBufferAndReset();
|
||||||
} else if( key == Key.PageUp ) {
|
} else if( key == Key.PageUp ) {
|
||||||
@ -238,7 +238,7 @@ namespace ClassicalSharp {
|
|||||||
if( chatIndex > game.Chat.Log.Count - chatLines )
|
if( chatIndex > game.Chat.Log.Count - chatLines )
|
||||||
chatIndex = game.Chat.Log.Count - chatLines;
|
chatIndex = game.Chat.Log.Count - chatLines;
|
||||||
ResetChat();
|
ResetChat();
|
||||||
} else if( key == game.Mapping( KeyMapping.HideGui ) ) {
|
} else if( key == game.Mapping( KeyBinding.HideGui ) ) {
|
||||||
game.HideGui = !game.HideGui;
|
game.HideGui = !game.HideGui;
|
||||||
} else {
|
} else {
|
||||||
textInput.HandlesKeyDown( key );
|
textInput.HandlesKeyDown( key );
|
||||||
@ -246,7 +246,7 @@ namespace ClassicalSharp {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( key == game.Mapping( KeyMapping.OpenChat ) ) {
|
if( key == game.Mapping( KeyBinding.OpenChat ) ) {
|
||||||
OpenTextInputBar( "" );
|
OpenTextInputBar( "" );
|
||||||
} else if( key == Key.Slash ) {
|
} else if( key == Key.Slash ) {
|
||||||
OpenTextInputBar( "/" );
|
OpenTextInputBar( "/" );
|
||||||
|
@ -4,9 +4,9 @@ using OpenTK.Input;
|
|||||||
|
|
||||||
namespace ClassicalSharp {
|
namespace ClassicalSharp {
|
||||||
|
|
||||||
public class KeyMappingsScreen : MenuScreen {
|
public class KeyBindingsScreen : MenuScreen {
|
||||||
|
|
||||||
public KeyMappingsScreen( Game game ) : base( game ) {
|
public KeyBindingsScreen( Game game ) : base( game ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
@ -43,9 +43,9 @@ namespace ClassicalSharp {
|
|||||||
void MakeKeys( int start, int len, int x ) {
|
void MakeKeys( int start, int len, int x ) {
|
||||||
int y = -180;
|
int y = -180;
|
||||||
for( int i = 0; i < len; i++ ) {
|
for( int i = 0; i < len; i++ ) {
|
||||||
KeyMapping mapping = (KeyMapping)( (int)start + i );
|
KeyBinding binding = (KeyBinding)((int)start + i);
|
||||||
string text = descriptions[start + i] + ": "
|
string text = descriptions[start + i] + ": "
|
||||||
+ keyNames[(int)game.Mapping( mapping )];
|
+ keyNames[(int)game.Mapping( binding )];
|
||||||
|
|
||||||
buttons[index++] = ButtonWidget.Create( game, x, y, 240, 25, text,
|
buttons[index++] = ButtonWidget.Create( game, x, y, 240, 25, text,
|
||||||
Anchor.Centre, Anchor.Centre, keyFont, OnWidgetClick );
|
Anchor.Centre, Anchor.Centre, keyFont, OnWidgetClick );
|
||||||
@ -68,7 +68,7 @@ namespace ClassicalSharp {
|
|||||||
game.SetNewScreen( new NormalScreen( game ) );
|
game.SetNewScreen( new NormalScreen( game ) );
|
||||||
} else if( widget != null ) {
|
} else if( widget != null ) {
|
||||||
int index = Array.IndexOf<ButtonWidget>( buttons, widget );
|
int index = Array.IndexOf<ButtonWidget>( buttons, widget );
|
||||||
KeyMapping mapping = (KeyMapping)index;
|
KeyBinding mapping = (KeyBinding)index;
|
||||||
KeyMap map = game.InputHandler.Keys;
|
KeyMap map = game.InputHandler.Keys;
|
||||||
Key oldKey = map[mapping];
|
Key oldKey = map[mapping];
|
||||||
string reason;
|
string reason;
|
@ -62,7 +62,7 @@ namespace ClassicalSharp {
|
|||||||
p.SetLocation( update, false );
|
p.SetLocation( update, false );
|
||||||
}
|
}
|
||||||
} catch( Exception ex ) {
|
} catch( Exception ex ) {
|
||||||
Utils.LogError( "Error while trying to load map: {0}{1}", Environment.NewLine, ex );
|
ErrorHandler.LogError( "loading map", ex );
|
||||||
game.Chat.Add( "&e/client loadmap: Failed to load map \"" + path + "\"" );
|
game.Chat.Add( "&e/client loadmap: Failed to load map \"" + path + "\"" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ namespace ClassicalSharp {
|
|||||||
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
||||||
Options.Set( OptionsKey.Sensitivity, v ); } ),
|
Options.Set( OptionsKey.Sensitivity, v ); } ),
|
||||||
|
|
||||||
Make( 140, 50, "Key mappings", Anchor.Centre,
|
Make( 140, 50, "Key bindings", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ), null, null ),
|
(g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ), null, null ),
|
||||||
// Extra stuff
|
// Extra stuff
|
||||||
!network.IsSinglePlayer ? null :
|
!network.IsSinglePlayer ? null :
|
||||||
Make( -140, -150, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
|
Make( -140, -150, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
|
||||||
|
@ -103,8 +103,8 @@ namespace ClassicalSharp {
|
|||||||
map.Save( fs, game );
|
map.Save( fs, game );
|
||||||
}
|
}
|
||||||
} catch( Exception ex ) {
|
} catch( Exception ex ) {
|
||||||
Utils.LogError( "Error while trying to save map: {0}{1}", Environment.NewLine, ex );
|
ErrorHandler.LogError( "saving map", ex );
|
||||||
MakeDescWidget( "&cFailed to save map" );
|
MakeDescWidget( "&cError while trying to save map" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
game.SetNewScreen( new PauseScreen( game ) );
|
game.SetNewScreen( new PauseScreen( game ) );
|
||||||
|
@ -31,7 +31,7 @@ namespace ClassicalSharp {
|
|||||||
if( playerList != null ) {
|
if( playerList != null ) {
|
||||||
playerList.Render( delta );
|
playerList.Render( delta );
|
||||||
// NOTE: Should usually be caught by KeyUp, but just in case.
|
// NOTE: Should usually be caught by KeyUp, but just in case.
|
||||||
if( !game.IsKeyDown( KeyMapping.PlayerList ) ) {
|
if( !game.IsKeyDown( KeyBinding.PlayerList ) ) {
|
||||||
playerList.Dispose();
|
playerList.Dispose();
|
||||||
playerList = null;
|
playerList = null;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyDown( Key key ) {
|
public override bool HandlesKeyDown( Key key ) {
|
||||||
if( key == game.Mapping( KeyMapping.PlayerList ) ) {
|
if( key == game.Mapping( KeyBinding.PlayerList ) ) {
|
||||||
if( playerList == null ) {
|
if( playerList == null ) {
|
||||||
if( game.Network.UsingExtPlayerList ) {
|
if( game.Network.UsingExtPlayerList ) {
|
||||||
playerList = new ExtPlayerListWidget( game, playerFont );
|
playerList = new ExtPlayerListWidget( game, playerFont );
|
||||||
@ -111,7 +111,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyUp( Key key ) {
|
public override bool HandlesKeyUp( Key key ) {
|
||||||
if( key == game.Mapping( KeyMapping.PlayerList ) ) {
|
if( key == game.Mapping( KeyBinding.PlayerList ) ) {
|
||||||
if( playerList != null ) {
|
if( playerList != null ) {
|
||||||
playerList.Dispose();
|
playerList.Dispose();
|
||||||
playerList = null;
|
playerList = null;
|
||||||
|
@ -41,7 +41,6 @@ namespace ClassicalSharp {
|
|||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
graphicsApi.Texturing = true;
|
graphicsApi.Texturing = true;
|
||||||
background.Render( graphicsApi );
|
background.Render( graphicsApi );
|
||||||
// TODO: Maybe redesign this so we don't have to bind the whole atlas. Not cheap.
|
|
||||||
graphicsApi.BindTexture( game.TerrainAtlas.TexId );
|
graphicsApi.BindTexture( game.TerrainAtlas.TexId );
|
||||||
graphicsApi.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
|
graphicsApi.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
<Compile Include="2D\Screens\FpsScreen.cs" />
|
<Compile Include="2D\Screens\FpsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\LoadingMapScreen.cs" />
|
<Compile Include="2D\Screens\LoadingMapScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\EnvSettingsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\EnvSettingsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\KeyMappingsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\KeyBindingsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\LoadLevelScreen.cs" />
|
<Compile Include="2D\Screens\Menu\LoadLevelScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\MenuInputScreen.cs" />
|
<Compile Include="2D\Screens\Menu\MenuInputScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
|
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
|
||||||
|
@ -99,15 +99,15 @@ namespace ClassicalSharp {
|
|||||||
if( game.ScreenLockedInput ) {
|
if( game.ScreenLockedInput ) {
|
||||||
jumping = speeding = flyingUp = flyingDown = false;
|
jumping = speeding = flyingUp = flyingDown = false;
|
||||||
} else {
|
} else {
|
||||||
if( game.IsKeyDown( KeyMapping.Forward ) ) xMoving -= 0.98f;
|
if( game.IsKeyDown( KeyBinding.Forward ) ) xMoving -= 0.98f;
|
||||||
if( game.IsKeyDown( KeyMapping.Back ) ) xMoving += 0.98f;
|
if( game.IsKeyDown( KeyBinding.Back ) ) xMoving += 0.98f;
|
||||||
if( game.IsKeyDown( KeyMapping.Left ) ) zMoving -= 0.98f;
|
if( game.IsKeyDown( KeyBinding.Left ) ) zMoving -= 0.98f;
|
||||||
if( game.IsKeyDown( KeyMapping.Right ) ) zMoving += 0.98f;
|
if( game.IsKeyDown( KeyBinding.Right ) ) zMoving += 0.98f;
|
||||||
|
|
||||||
jumping = game.IsKeyDown( KeyMapping.Jump );
|
jumping = game.IsKeyDown( KeyBinding.Jump );
|
||||||
speeding = canSpeed && game.IsKeyDown( KeyMapping.Speed );
|
speeding = canSpeed && game.IsKeyDown( KeyBinding.Speed );
|
||||||
flyingUp = game.IsKeyDown( KeyMapping.FlyUp );
|
flyingUp = game.IsKeyDown( KeyBinding.FlyUp );
|
||||||
flyingDown = game.IsKeyDown( KeyMapping.FlyDown );
|
flyingDown = game.IsKeyDown( KeyBinding.FlyDown );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
internal bool HandleKeyDown( Key key ) {
|
internal bool HandleKeyDown( Key key ) {
|
||||||
KeyMap keys = game.InputHandler.Keys;
|
KeyMap keys = game.InputHandler.Keys;
|
||||||
if( key == keys[KeyMapping.Respawn] && canRespawn ) {
|
if( key == keys[KeyBinding.Respawn] && canRespawn ) {
|
||||||
Vector3I p = Vector3I.Floor( SpawnPoint );
|
Vector3I p = Vector3I.Floor( SpawnPoint );
|
||||||
if( game.Map.IsValidPos( p ) ) {
|
if( game.Map.IsValidPos( p ) ) {
|
||||||
// Spawn player at highest valid position.
|
// Spawn player at highest valid position.
|
||||||
@ -283,11 +283,11 @@ namespace ClassicalSharp {
|
|||||||
Vector3 spawn = (Vector3)p + new Vector3( 0.5f, 0.01f, 0.5f );
|
Vector3 spawn = (Vector3)p + new Vector3( 0.5f, 0.01f, 0.5f );
|
||||||
LocationUpdate update = LocationUpdate.MakePos( spawn, false );
|
LocationUpdate update = LocationUpdate.MakePos( spawn, false );
|
||||||
SetLocation( update, false );
|
SetLocation( update, false );
|
||||||
} else if( key == keys[KeyMapping.SetSpawn] && canRespawn ) {
|
} else if( key == keys[KeyBinding.SetSpawn] && canRespawn ) {
|
||||||
SpawnPoint = Position;
|
SpawnPoint = Position;
|
||||||
} else if( key == keys[KeyMapping.Fly] && canFly ) {
|
} else if( key == keys[KeyBinding.Fly] && canFly ) {
|
||||||
flying = !flying;
|
flying = !flying;
|
||||||
} else if( key == keys[KeyMapping.NoClip] && canNoclip ) {
|
} else if( key == keys[KeyBinding.NoClip] && canNoclip ) {
|
||||||
noClip = !noClip;
|
noClip = !noClip;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,7 +55,7 @@ namespace ClassicalSharp {
|
|||||||
MobTextureId = -1;
|
MobTextureId = -1;
|
||||||
|
|
||||||
// Custom mob textures.
|
// Custom mob textures.
|
||||||
if( Utils.IsUrl( item.Url ) && item.TimeAdded > lastModelChange ) {
|
if( Utils.IsUrlPrefix( item.Url ) && item.TimeAdded > lastModelChange ) {
|
||||||
MobTextureId = PlayerTextureId;
|
MobTextureId = PlayerTextureId;
|
||||||
}
|
}
|
||||||
RenderHat = HasHat( bmp, SkinType );
|
RenderHat = HasHat( bmp, SkinType );
|
||||||
|
@ -92,11 +92,12 @@ namespace ClassicalSharp {
|
|||||||
Directory.CreateDirectory( "logs" );
|
Directory.CreateDirectory( "logs" );
|
||||||
|
|
||||||
string date = now.ToString( "yyyy-MM-dd" );
|
string date = now.ToString( "yyyy-MM-dd" );
|
||||||
// Cheap way of ensuring multiple instances do not end up overwriting each other's log entries.
|
// Ensure multiple instances do not end up overwriting each other's log entries.
|
||||||
for( int i = 0; i < 20; i++ ) {
|
for( int i = 0; i < 20; i++ ) {
|
||||||
string id = i == 0 ? "" : " _" + i;
|
string id = i == 0 ? "" : " _" + i;
|
||||||
string fileName = "chat-" + date + id + ".log";
|
string fileName = "chat-" + date + id + ".log";
|
||||||
string path = Path.Combine( "logs", fileName );
|
string path = Path.Combine( "logs", fileName );
|
||||||
|
|
||||||
FileStream stream = null;
|
FileStream stream = null;
|
||||||
try {
|
try {
|
||||||
stream = File.Open( path, FileMode.Append, FileAccess.Write, FileShare.Read );
|
stream = File.Open( path, FileMode.Append, FileAccess.Write, FileShare.Read );
|
||||||
@ -105,12 +106,13 @@ namespace ClassicalSharp {
|
|||||||
throw;
|
throw;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Utils.LogDebug( "opening chat with id:" + id );
|
|
||||||
writer = new StreamWriter( stream );
|
writer = new StreamWriter( stream );
|
||||||
writer.AutoFlush = true;
|
writer.AutoFlush = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils.LogError( "Failed to open or create a chat log file after 20 tries, giving up." );
|
ErrorHandler.LogError( "creating chat log",
|
||||||
|
"Failed to open or create a chat log file after 20 tries, giving up." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,15 +261,15 @@ namespace ClassicalSharp {
|
|||||||
cameraAccumulator -= cameraPeriod;
|
cameraAccumulator -= cameraPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ticksThisFrame > ticksFrequency / 3 ) {
|
if( ticksThisFrame > ticksFrequency / 3 )
|
||||||
Utils.LogWarning( "Falling behind (did {0} ticks this frame)", ticksThisFrame );
|
Utils.LogWarning( "Falling behind (did {0} ticks this frame)", ticksThisFrame );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TakeScreenshot() {
|
void TakeScreenshot() {
|
||||||
if( !Directory.Exists( "screenshots" ) ) {
|
if( !Directory.Exists( "screenshots" ) ) {
|
||||||
Directory.CreateDirectory( "screenshots" );
|
Directory.CreateDirectory( "screenshots" );
|
||||||
}
|
}
|
||||||
|
|
||||||
string timestamp = DateTime.Now.ToString( "dd-MM-yyyy-HH-mm-ss" );
|
string timestamp = DateTime.Now.ToString( "dd-MM-yyyy-HH-mm-ss" );
|
||||||
string path = Path.Combine( "screenshots", "screenshot_" + timestamp + ".png" );
|
string path = Path.Combine( "screenshots", "screenshot_" + timestamp + ".png" );
|
||||||
Graphics.TakeScreenshot( path, ClientSize );
|
Graphics.TakeScreenshot( path, ClientSize );
|
||||||
@ -333,11 +333,11 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public bool IsKeyDown( Key key ) { return InputHandler.IsKeyDown( key ); }
|
public bool IsKeyDown( Key key ) { return InputHandler.IsKeyDown( key ); }
|
||||||
|
|
||||||
public bool IsKeyDown( KeyMapping mapping ) { return InputHandler.IsKeyDown( mapping ); }
|
public bool IsKeyDown( KeyBinding binding ) { return InputHandler.IsKeyDown( binding ); }
|
||||||
|
|
||||||
public bool IsMousePressed( MouseButton button ) { return InputHandler.IsMousePressed( button ); }
|
public bool IsMousePressed( MouseButton button ) { return InputHandler.IsMousePressed( button ); }
|
||||||
|
|
||||||
public Key Mapping( KeyMapping mapping ) { return InputHandler.Keys[mapping]; }
|
public Key Mapping( KeyBinding mapping ) { return InputHandler.Keys[mapping]; }
|
||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
MapRenderer.Dispose();
|
MapRenderer.Dispose();
|
||||||
|
@ -38,8 +38,9 @@ namespace ClassicalSharp {
|
|||||||
return game.Keyboard[key];
|
return game.Keyboard[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsKeyDown( KeyMapping mapping ) {
|
/// <summary> Returns whether the key associated with the given key binding is currently held down. </summary>
|
||||||
Key key = Keys[mapping];
|
public bool IsKeyDown( KeyBinding binding ) {
|
||||||
|
Key key = Keys[binding];
|
||||||
return game.Keyboard[key];
|
return game.Keyboard[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +268,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
if( key == Key.F4 && (game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight )) ) {
|
if( key == Key.F4 && (game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight )) ) {
|
||||||
game.Exit();
|
game.Exit();
|
||||||
} else if( key == Keys[KeyMapping.Screenshot] ) {
|
} else if( key == Keys[KeyBinding.Screenshot] ) {
|
||||||
game.screenshotRequested = true;
|
game.screenshotRequested = true;
|
||||||
} else if( game.activeScreen == null || !game.activeScreen.HandlesKeyDown( key ) ) {
|
} else if( game.activeScreen == null || !game.activeScreen.HandlesKeyDown( key ) ) {
|
||||||
|
|
||||||
@ -308,26 +309,26 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool HandleBuiltinKey( Key key ) {
|
bool HandleBuiltinKey( Key key ) {
|
||||||
if( key == Keys[KeyMapping.HideGui] ) {
|
if( key == Keys[KeyBinding.HideGui] ) {
|
||||||
game.HideGui = !game.HideGui;
|
game.HideGui = !game.HideGui;
|
||||||
} else if( key == Keys[KeyMapping.Fullscreen] ) {
|
} else if( key == Keys[KeyBinding.Fullscreen] ) {
|
||||||
WindowState state = game.WindowState;
|
WindowState state = game.WindowState;
|
||||||
if( state != WindowState.Minimized ) {
|
if( state != WindowState.Minimized ) {
|
||||||
game.WindowState = state == WindowState.Fullscreen ?
|
game.WindowState = state == WindowState.Fullscreen ?
|
||||||
WindowState.Normal : WindowState.Fullscreen;
|
WindowState.Normal : WindowState.Fullscreen;
|
||||||
}
|
}
|
||||||
} else if( key == Keys[KeyMapping.ThirdPersonCamera] ) {
|
} else if( key == Keys[KeyBinding.ThirdPersonCamera] ) {
|
||||||
bool useThirdPerson = !(game.Camera is ForwardThirdPersonCamera);
|
bool useThirdPerson = !(game.Camera is ForwardThirdPersonCamera);
|
||||||
game.SetCamera( useThirdPerson );
|
game.SetCamera( useThirdPerson );
|
||||||
} else if( key == Keys[KeyMapping.ViewDistance] ) {
|
} else if( key == Keys[KeyBinding.ViewDistance] ) {
|
||||||
if( game.IsKeyDown( Key.ShiftLeft ) || game.IsKeyDown( Key.ShiftRight ) ) {
|
if( game.IsKeyDown( Key.ShiftLeft ) || game.IsKeyDown( Key.ShiftRight ) ) {
|
||||||
CycleDistanceBackwards();
|
CycleDistanceBackwards();
|
||||||
} else {
|
} else {
|
||||||
CycleDistanceForwards();
|
CycleDistanceForwards();
|
||||||
}
|
}
|
||||||
} else if( key == Keys[KeyMapping.PauseOrExit] && !game.Map.IsNotLoaded ) {
|
} else if( key == Keys[KeyBinding.PauseOrExit] && !game.Map.IsNotLoaded ) {
|
||||||
game.SetNewScreen( new PauseScreen( game ) );
|
game.SetNewScreen( new PauseScreen( game ) );
|
||||||
} else if( key == Keys[KeyMapping.OpenInventory] ) {
|
} else if( key == Keys[KeyBinding.OpenInventory] ) {
|
||||||
game.SetNewScreen( new BlockSelectScreen( game ) );
|
game.SetNewScreen( new BlockSelectScreen( game ) );
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,7 +3,7 @@ using OpenTK.Input;
|
|||||||
|
|
||||||
namespace ClassicalSharp {
|
namespace ClassicalSharp {
|
||||||
|
|
||||||
public enum KeyMapping {
|
public enum KeyBinding {
|
||||||
Forward, Back, Left, Right, Jump, Respawn, SetSpawn, OpenChat,
|
Forward, Back, Left, Right, Jump, Respawn, SetSpawn, OpenChat,
|
||||||
SendChat, PauseOrExit, OpenInventory, Screenshot, Fullscreen,
|
SendChat, PauseOrExit, OpenInventory, Screenshot, Fullscreen,
|
||||||
ThirdPersonCamera, ViewDistance, Fly, Speed, NoClip, FlyUp,
|
ThirdPersonCamera, ViewDistance, Fly, Speed, NoClip, FlyUp,
|
||||||
@ -12,7 +12,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public class KeyMap {
|
public class KeyMap {
|
||||||
|
|
||||||
public Key this[KeyMapping key] {
|
public Key this[KeyBinding key] {
|
||||||
get { return Keys[(int)key]; }
|
get { return Keys[(int)key]; }
|
||||||
set { Keys[(int)key] = value; SaveKeyBindings(); }
|
set { Keys[(int)key] = value; SaveKeyBindings(); }
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public bool IsKeyOkay( Key oldKey, Key key, out string reason ) {
|
public bool IsKeyOkay( Key oldKey, Key key, out string reason ) {
|
||||||
if( oldKey == Key.Escape || oldKey == Key.F12 ) {
|
if( oldKey == Key.Escape || oldKey == Key.F12 ) {
|
||||||
reason = "This mapping is locked";
|
reason = "This binding is locked";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoadKeyBindings() {
|
void LoadKeyBindings() {
|
||||||
string[] names = KeyMapping.GetNames( typeof( KeyMapping ) );
|
string[] names = KeyBinding.GetNames( typeof( KeyBinding ) );
|
||||||
for( int i = 0; i < names.Length; i++ ) {
|
for( int i = 0; i < names.Length; i++ ) {
|
||||||
string key = "key-" + names[i];
|
string key = "key-" + names[i];
|
||||||
Key mapping = Options.GetKey( key, Keys[i] );
|
Key mapping = Options.GetKey( key, Keys[i] );
|
||||||
@ -71,7 +71,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SaveKeyBindings() {
|
void SaveKeyBindings() {
|
||||||
string[] names = KeyMapping.GetNames( typeof( KeyMapping ) );
|
string[] names = KeyBinding.GetNames( typeof( KeyBinding ) );
|
||||||
for( int i = 0; i < names.Length; i++ ) {
|
for( int i = 0; i < names.Length; i++ ) {
|
||||||
Options.Set( "key-" + names[i], Keys[i] );
|
Options.Set( "key-" + names[i], Keys[i] );
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using WinWindowInfo = OpenTK.Platform.Windows.WinWindowInfo;
|
|||||||
|
|
||||||
namespace ClassicalSharp.GraphicsAPI {
|
namespace ClassicalSharp.GraphicsAPI {
|
||||||
|
|
||||||
|
/// <summary> Implemented IGraphicsAPI using Direct3D 9. </summary>
|
||||||
public class Direct3D9Api : IGraphicsApi {
|
public class Direct3D9Api : IGraphicsApi {
|
||||||
|
|
||||||
Device device;
|
Device device;
|
||||||
|
@ -9,7 +9,6 @@ using OpenTK.Graphics.OpenGL;
|
|||||||
namespace ClassicalSharp.GraphicsAPI {
|
namespace ClassicalSharp.GraphicsAPI {
|
||||||
|
|
||||||
/// <summary> Abstracts a 3D graphics rendering API. </summary>
|
/// <summary> Abstracts a 3D graphics rendering API. </summary>
|
||||||
/// <remarks> Only Direct3D9 and OpenGL support are implemented. </remarks>
|
|
||||||
public abstract class IGraphicsApi {
|
public abstract class IGraphicsApi {
|
||||||
|
|
||||||
/// <summary> Maximum supported length of a dimension (width and height) of a 2D texture. </summary>
|
/// <summary> Maximum supported length of a dimension (width and height) of a 2D texture. </summary>
|
||||||
|
@ -9,6 +9,8 @@ using GlPixelFormat = OpenTK.Graphics.OpenGL.PixelFormat;
|
|||||||
|
|
||||||
namespace ClassicalSharp.GraphicsAPI {
|
namespace ClassicalSharp.GraphicsAPI {
|
||||||
|
|
||||||
|
/// <summary> Implemented IGraphicsAPI using OpenGL 1.5,
|
||||||
|
/// or 1.2 with the GL_ARB_vertex_buffer_object extension. </summary>
|
||||||
public class OpenGLApi : IGraphicsApi {
|
public class OpenGLApi : IGraphicsApi {
|
||||||
|
|
||||||
BeginMode[] modeMappings;
|
BeginMode[] modeMappings;
|
||||||
@ -35,9 +37,13 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
Utils.LogDebug( "Using ARB vertex buffer objects" );
|
Utils.LogDebug( "Using ARB vertex buffer objects" );
|
||||||
if( !extensions.Contains( "GL_ARB_vertex_buffer_object" ) ) {
|
if( !extensions.Contains( "GL_ARB_vertex_buffer_object" ) ) {
|
||||||
Utils.LogError( "ClassicalSharp post 0.6 version requires OpenGL VBOs." );
|
Utils.LogWarning( "ClassicalSharp post 0.6 version requires OpenGL VBOs." );
|
||||||
Utils.LogWarning( "You may need to install and/or update your video card drivers." );
|
Utils.LogWarning( "You may need to install and/or update your video card drivers." );
|
||||||
Utils.LogWarning( "Alternatively, you can download the Direct3D9 build." );
|
Utils.LogWarning( "Alternatively, you can download the Direct3D9 build." );
|
||||||
|
|
||||||
|
ErrorHandler.LogError( "OpenGL vbo check",
|
||||||
|
"Driver does not support OpenGL VBOs, which are required for the OpenGL build." +
|
||||||
|
Environment.NewLine + "you may need to install and/or update video card drivers" );
|
||||||
throw new InvalidOperationException( "VBO support required for OpenGL build" );
|
throw new InvalidOperationException( "VBO support required for OpenGL build" );
|
||||||
}
|
}
|
||||||
GL.UseArbVboAddresses();
|
GL.UseArbVboAddresses();
|
||||||
|
@ -36,14 +36,8 @@ namespace ClassicalSharp.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( !cache.TryGetValue( modelName, out model ) ) {
|
if( !cache.TryGetValue( modelName, out model ) ) {
|
||||||
try {
|
|
||||||
model = InitModel( modelName );
|
model = InitModel( modelName );
|
||||||
} catch( FileNotFoundException ) {
|
if( model == null ) model = cache["humanoid"]; // fallback to default
|
||||||
model = null;
|
|
||||||
Utils.LogWarning( modelName + " not found, falling back to human default." );
|
|
||||||
}
|
|
||||||
if( model == null )
|
|
||||||
model = cache["humanoid"]; // fallback to default
|
|
||||||
cache[modelName] = model;
|
cache[modelName] = model;
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
|
@ -35,7 +35,7 @@ namespace ClassicalSharp {
|
|||||||
try {
|
try {
|
||||||
socket.Connect( address, port );
|
socket.Connect( address, port );
|
||||||
} catch( SocketException ex ) {
|
} catch( SocketException ex ) {
|
||||||
Utils.LogError( "Error while trying to connect: {0}{1}", Environment.NewLine, ex );
|
ErrorHandler.LogError( "connecting to server", ex );
|
||||||
game.Disconnect( "&eUnable to reach " + address + ":" + port,
|
game.Disconnect( "&eUnable to reach " + address + ":" + port,
|
||||||
"Unable to establish an underlying connection" );
|
"Unable to establish an underlying connection" );
|
||||||
Dispose();
|
Dispose();
|
||||||
@ -98,8 +98,8 @@ namespace ClassicalSharp {
|
|||||||
try {
|
try {
|
||||||
reader.ReadPendingData();
|
reader.ReadPendingData();
|
||||||
} catch( IOException ex ) {
|
} catch( IOException ex ) {
|
||||||
Utils.LogError( "Error while reading packets: {0}{1}", Environment.NewLine, ex );
|
ErrorHandler.LogError( "reading packets", ex );
|
||||||
game.Disconnect( "&eLost connection to the server", "Underlying connection was closed" );
|
game.Disconnect( "&eLost connection to the server", "IO error when reading packets" );
|
||||||
Dispose();
|
Dispose();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -204,8 +204,8 @@ namespace ClassicalSharp {
|
|||||||
try {
|
try {
|
||||||
stream.Write( outBuffer, 0, packetLength );
|
stream.Write( outBuffer, 0, packetLength );
|
||||||
} catch( IOException ex ) {
|
} catch( IOException ex ) {
|
||||||
Utils.LogError( "Error while writing packets: {0}{1}", Environment.NewLine, ex );
|
ErrorHandler.LogError( "wrting packets", ex );
|
||||||
game.Disconnect( "&eLost connection to the server", "Underlying connection was closed" );
|
game.Disconnect( "&eLost connection to the server", "IO Error while writing packets" );
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,6 +254,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
receivedFirstPosition = false;
|
receivedFirstPosition = false;
|
||||||
gzipHeader = new GZipHeaderReader();
|
gzipHeader = new GZipHeaderReader();
|
||||||
|
|
||||||
// Workaround because built in mono stream assumes that the end of stream
|
// Workaround because built in mono stream assumes that the end of stream
|
||||||
// has been reached the first time a read call returns 0. (MS.NET doesn't)
|
// has been reached the first time a read call returns 0. (MS.NET doesn't)
|
||||||
#if __MonoCS__
|
#if __MonoCS__
|
||||||
@ -261,10 +262,8 @@ namespace ClassicalSharp {
|
|||||||
#else
|
#else
|
||||||
gzipStream = new DeflateStream( gzippedMap, CompressionMode.Decompress );
|
gzipStream = new DeflateStream( gzippedMap, CompressionMode.Decompress );
|
||||||
if( OpenTK.Configuration.RunningOnMono ) {
|
if( OpenTK.Configuration.RunningOnMono ) {
|
||||||
Utils.LogWarning( "You are running on Mono, but this build does not support the Mono workaround." );
|
throw new InvalidOperationException( "You must compile ClassicalSharp with the mono compiler " +
|
||||||
Utils.LogWarning( "You should either download the Mono compatible build or define '__MonoCS__' when targeting Mono. " +
|
"to run on Mono, due to a limitation in Mono." );
|
||||||
"(The Mono compiler already defines this by default)" );
|
|
||||||
Utils.LogWarning( "You will likely experience an 'Internal error (no progress possible) ReadInternal' exception when decompressing the map." );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace ClassicalSharp.Network {
|
|||||||
/// <remarks> Identifier is skin_'skinName'.</remarks>
|
/// <remarks> Identifier is skin_'skinName'.</remarks>
|
||||||
public void DownloadSkin( string skinName ) {
|
public void DownloadSkin( string skinName ) {
|
||||||
string strippedSkinName = Utils.StripColours( skinName );
|
string strippedSkinName = Utils.StripColours( skinName );
|
||||||
string url = Utils.IsUrl( skinName ) ? skinName :
|
string url = Utils.IsUrlPrefix( skinName ) ? skinName :
|
||||||
skinServer + strippedSkinName + ".png";
|
skinServer + strippedSkinName + ".png";
|
||||||
AddRequest( url, true, "skin_" + strippedSkinName, 0 );
|
AddRequest( url, true, "skin_" + strippedSkinName, 0 );
|
||||||
}
|
}
|
||||||
|
@ -48,13 +48,20 @@ namespace ClassicalSharp {
|
|||||||
Environment.Exit( 1 );
|
Environment.Exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool LogHandledException( Exception ex ) {
|
/// <summary> Logs a handled exception that occured at the specified location to the log file. </summary>
|
||||||
string error = ex.GetType().FullName + ": " + ex.Message + Environment.NewLine + ex.StackTrace;
|
public static bool LogError( string location, Exception ex ) {
|
||||||
|
string error = ex.GetType().FullName + ": " + ex.Message
|
||||||
|
+ Environment.NewLine + ex.StackTrace;
|
||||||
|
return LogError( location, error );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Logs an error that occured at the specified location to the log file. </summary>
|
||||||
|
public static bool LogError( string location, string text ) {
|
||||||
try {
|
try {
|
||||||
using( StreamWriter writer = new StreamWriter( crashFile, true ) ) {
|
using( StreamWriter writer = new StreamWriter( crashFile, true ) ) {
|
||||||
writer.WriteLine( "--- handled error ---" );
|
writer.WriteLine( "--- handled error ---" );
|
||||||
writer.WriteLine( error );
|
writer.WriteLine( "Occured when: " + location );
|
||||||
|
writer.WriteLine( text );
|
||||||
writer.WriteLine();
|
writer.WriteLine();
|
||||||
}
|
}
|
||||||
} catch( Exception ) {
|
} catch( Exception ) {
|
||||||
|
@ -19,8 +19,6 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public static class Utils {
|
public static class Utils {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Clamps that specified value such that min ≤ value ≤ max </summary>
|
/// <summary> Clamps that specified value such that min ≤ value ≤ max </summary>
|
||||||
public static void Clamp( ref float value, float min, float max ) {
|
public static void Clamp( ref float value, float min, float max ) {
|
||||||
if( value < min ) value = min;
|
if( value < min ) value = min;
|
||||||
@ -67,14 +65,17 @@ namespace ClassicalSharp {
|
|||||||
return new String( output, 0, usedChars );
|
return new String( output, 0, usedChars );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns whether a equals b, ignoring any case differences. </summary>
|
||||||
public static bool CaselessEquals( string a, string b ) {
|
public static bool CaselessEquals( string a, string b ) {
|
||||||
return a.Equals( b, StringComparison.OrdinalIgnoreCase );
|
return a.Equals( b, StringComparison.OrdinalIgnoreCase );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns whether a starts with b, ignoring any case differences. </summary>
|
||||||
public static bool CaselessStarts( string a, string b ) {
|
public static bool CaselessStarts( string a, string b ) {
|
||||||
return a.StartsWith( b, StringComparison.OrdinalIgnoreCase );
|
return a.StartsWith( b, StringComparison.OrdinalIgnoreCase );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Converts the given byte array of length N to a hex string of length 2N. </summary>
|
||||||
public static string ToHexString( byte[] array ) {
|
public static string ToHexString( byte[] array ) {
|
||||||
int len = array.Length;
|
int len = array.Length;
|
||||||
char[] hexadecimal = new char[len * 2];
|
char[] hexadecimal = new char[len * 2];
|
||||||
@ -117,38 +118,46 @@ namespace ClassicalSharp {
|
|||||||
return packed * 360.0 / 256.0;
|
return packed * 360.0 / 256.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||||
public static Vector3 RotateY( Vector3 v, float angle ) {
|
public static Vector3 RotateY( Vector3 v, float angle ) {
|
||||||
float cosA = (float)Math.Cos( angle );
|
float cosA = (float)Math.Cos( angle );
|
||||||
float sinA = (float)Math.Sin( angle );
|
float sinA = (float)Math.Sin( angle );
|
||||||
return new Vector3( cosA * v.X - sinA * v.Z, v.Y, sinA * v.X + cosA * v.Z );
|
return new Vector3( cosA * v.X - sinA * v.Z, v.Y, sinA * v.X + cosA * v.Z );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||||
public static Vector3 RotateY( float x, float y, float z, float angle ) {
|
public static Vector3 RotateY( float x, float y, float z, float angle ) {
|
||||||
float cosA = (float)Math.Cos( angle );
|
float cosA = (float)Math.Cos( angle );
|
||||||
float sinA = (float)Math.Sin( angle );
|
float sinA = (float)Math.Sin( angle );
|
||||||
return new Vector3( cosA * x - sinA * z, y, sinA * x + cosA * z );
|
return new Vector3( cosA * x - sinA * z, y, sinA * x + cosA * z );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Rotates the given 3D coordinates around the x axis. </summary>
|
||||||
public static Vector3 RotateX( Vector3 p, float cosA, float sinA ) {
|
public static Vector3 RotateX( Vector3 p, float cosA, float sinA ) {
|
||||||
return new Vector3( p.X, cosA * p.Y + sinA * p.Z, -sinA * p.Y + cosA * p.Z );
|
return new Vector3( p.X, cosA * p.Y + sinA * p.Z, -sinA * p.Y + cosA * p.Z );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 RotateY( Vector3 p, float cosA, float sinA ) {
|
/// <summary> Rotates the given 3D coordinates around the x axis. </summary>
|
||||||
return new Vector3( cosA * p.X - sinA * p.Z, p.Y, sinA * p.X + cosA * p.Z );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3 RotateZ( Vector3 p, float cosA, float sinA ) {
|
|
||||||
return new Vector3( cosA * p.X + sinA * p.Y, -sinA * p.X + cosA * p.Y, p.Z );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3 RotateX( float x, float y, float z, float cosA, float sinA ) {
|
public static Vector3 RotateX( float x, float y, float z, float cosA, float sinA ) {
|
||||||
return new Vector3( x, cosA * y + sinA * z, -sinA * y + cosA * z );
|
return new Vector3( x, cosA * y + sinA * z, -sinA * y + cosA * z );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||||
|
public static Vector3 RotateY( Vector3 p, float cosA, float sinA ) {
|
||||||
|
return new Vector3( cosA * p.X - sinA * p.Z, p.Y, sinA * p.X + cosA * p.Z );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||||
public static Vector3 RotateY( float x, float y, float z, float cosA, float sinA ) {
|
public static Vector3 RotateY( float x, float y, float z, float cosA, float sinA ) {
|
||||||
return new Vector3( cosA * x - sinA * z, y, sinA * x + cosA * z );
|
return new Vector3( cosA * x - sinA * z, y, sinA * x + cosA * z );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Rotates the given 3D coordinates around the z axis. </summary>
|
||||||
|
public static Vector3 RotateZ( Vector3 p, float cosA, float sinA ) {
|
||||||
|
return new Vector3( cosA * p.X + sinA * p.Y, -sinA * p.X + cosA * p.Y, p.Z );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Rotates the given 3D coordinates around the z axis. </summary>
|
||||||
public static Vector3 RotateZ( float x, float y, float z, float cosA, float sinA ) {
|
public static Vector3 RotateZ( float x, float y, float z, float cosA, float sinA ) {
|
||||||
return new Vector3( cosA * x + sinA * y, -sinA * x + cosA * y, z );
|
return new Vector3( cosA * x + sinA * y, -sinA * x + cosA * y, z );
|
||||||
}
|
}
|
||||||
@ -177,6 +186,8 @@ namespace ClassicalSharp {
|
|||||||
return dx * dx + dy * dy + dz * dz;
|
return dx * dx + dy * dy + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns a normalised vector that faces in the direction
|
||||||
|
/// described by the given yaw and pitch. </summary>
|
||||||
public static Vector3 GetDirVector( double yawRad, double pitchRad ) {
|
public static Vector3 GetDirVector( double yawRad, double pitchRad ) {
|
||||||
double x = -Math.Cos( pitchRad ) * -Math.Sin( yawRad );
|
double x = -Math.Cos( pitchRad ) * -Math.Sin( yawRad );
|
||||||
double y = -Math.Sin( pitchRad );
|
double y = -Math.Sin( pitchRad );
|
||||||
@ -202,16 +213,6 @@ namespace ClassicalSharp {
|
|||||||
LogWarning( String.Format( text, args ) );
|
LogWarning( String.Format( text, args ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogError( string text ) {
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
|
||||||
Console.WriteLine( text );
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LogError( string text, params object[] args ) {
|
|
||||||
LogError( String.Format( text, args ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LogDebug( string text ) {
|
public static void LogDebug( string text ) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
@ -275,7 +276,8 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsUrl( string value ) {
|
/// <summary> Returns whether the specified string starts with http:// or https:// </summary>
|
||||||
|
public static bool IsUrlPrefix( string value ) {
|
||||||
return value.StartsWith( "http://" ) || value.StartsWith( "https://" );
|
return value.StartsWith( "http://" ) || value.StartsWith( "https://" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ namespace Launcher2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DisplayWebException( WebException ex, string action ) {
|
void DisplayWebException( WebException ex, string action ) {
|
||||||
Program.LogException( ex );
|
ErrorHandler.LogError( action, ex );
|
||||||
if( ex.Status == WebExceptionStatus.Timeout ) {
|
if( ex.Status == WebExceptionStatus.Timeout ) {
|
||||||
string text = "&eFailed to " + action + ":" +
|
string text = "&eFailed to " + action + ":" +
|
||||||
Environment.NewLine + "Timed out while connecting to classicube.net.";
|
Environment.NewLine + "Timed out while connecting to classicube.net.";
|
||||||
|
@ -65,7 +65,7 @@ namespace Launcher2 {
|
|||||||
try {
|
try {
|
||||||
data = Session.GetConnectInfo( hash );
|
data = Session.GetConnectInfo( hash );
|
||||||
} catch( WebException ex ) {
|
} catch( WebException ex ) {
|
||||||
Program.LogException( ex );
|
ErrorHandler.LogError( "retrieving server information", ex );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Client.Start( data, true );
|
Client.Start( data, true );
|
||||||
|
@ -13,9 +13,5 @@ namespace Launcher2 {
|
|||||||
LauncherWindow window = new LauncherWindow();
|
LauncherWindow window = new LauncherWindow();
|
||||||
window.Run();
|
window.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool LogException( Exception ex ) {
|
|
||||||
return ErrorHandler.LogHandledException( ex );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user