Skip to content

Commit

Permalink
Added camera controls to the status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
kraifpatrik committed Feb 3, 2019
1 parent 74020af commit b0f5f18
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 61 deletions.
45 changes: 1 addition & 44 deletions PushEd.gmx/scripts/PEd_cameraControl.gml
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,25 @@ if (guiInputActive != noone
// Camera speed
//
if (keyboard_check_pressed(vk_numpad0))
{
camSpeed = 0.5;
}
else if (keyboard_check_pressed(vk_numpad1))
{
camSpeed = 1;
}
else if (keyboard_check_pressed(vk_numpad2))
{
camSpeed = 4;
}
else if (keyboard_check_pressed(vk_numpad3))
{
camSpeed = 6;
}
else if (keyboard_check_pressed(vk_numpad4))
{
camSpeed = 8;
}
else if (keyboard_check_pressed(vk_numpad5))
{
camSpeed = 10;
}
else if (keyboard_check_pressed(vk_numpad6))
{
camSpeed = 12;
}
else if (keyboard_check_pressed(vk_numpad7))
{
camSpeed = 14;
}
else if (keyboard_check_pressed(vk_numpad8))
{
camSpeed = 16;
}
else if (keyboard_check_pressed(vk_numpad9))
{
camSpeed = 18;
}

////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -82,9 +62,7 @@ if (mouseInViewport)
var _wheel = mouse_wheel_up() - mouse_wheel_down();

if (_wheel == 0)
{
_wheel = (keyboard_check(vk_pageup) - keyboard_check(vk_pagedown)) * 0.25;
}

if (_wheel != 0)
{
Expand All @@ -107,21 +85,14 @@ if (global.pedUsing3D)
// Look around with arrows
//
if (keyboard_check(vk_left))
{
direction += 3;
}
else if (keyboard_check(vk_right))
{
direction -= 3;
}

if (keyboard_check(vk_up))
{
camPitch = clamp(camPitch + 3, -89, 89);
}
else if (keyboard_check(vk_down))
{
camPitch = clamp(camPitch - 3, -89, 89);
}

////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -136,9 +107,7 @@ if (global.pedUsing3D)

// Run
if (keyboard_check(vk_shift))
{
_run = 4;
}

var _speed = camSpeed * _run;

Expand Down Expand Up @@ -179,9 +148,7 @@ if (global.pedUsing3D)
var _l = camSpeed * 10;

if (keyboard_check(vk_shift))
{
_l *= 2;
}

x += lengthdir_x(_l, direction) * (mouse_wheel_up() - mouse_wheel_down());
y += lengthdir_y(_l, direction) * (mouse_wheel_up() - mouse_wheel_down());
Expand All @@ -197,25 +164,15 @@ else
var _speed = camSpeed * 5;

if (keyboard_check(vk_shift))
{
_speed *= 4;
}

if (keyboard_check(vk_left))
{
view_xview[0] -= _speed;
}
else if (keyboard_check(vk_right))
{
view_xview[0] += _speed;
}

if (keyboard_check(vk_up))
{
view_yview[0] -= _speed;
}
else if (keyboard_check(vk_down))
{
view_yview[0] += _speed;
}
}
71 changes: 54 additions & 17 deletions PushEd.gmx/scripts/PEd_guiContentStatusBar.gml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var _textY = round((_containerHeight - guiFontHeight) * 0.5);
var _text;

var _inputWidth = 64;
var _inputWidthPlusPadding = _inputWidth + _padding;

var _input;

PEd_guiDrawRectangle(0, 0, _containerWidth, 1, PEdColour.WindowBorder);
Expand All @@ -30,24 +32,18 @@ _x += string_width(_text) + _padding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, PEd_roomGetSnapH(_room));
if (!is_undefined(_input))
{
PEd_roomSetSnapH(_room, max(1, _input));
}
_x += _inputWidth + _padding;
_x += _inputWidthPlusPadding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, PEd_roomGetSnapV(_room));
if (!is_undefined(_input))
{
PEd_roomSetSnapV(_room, max(1, _input));
}
_x += _inputWidth + _padding;
_x += _inputWidthPlusPadding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, PEd_roomGetSnapD(_room));
if (!is_undefined(_input))
{
PEd_roomSetSnapD(_room, max(1, _input));
}
_x += _inputWidth + _padding;
_x += _inputWidthPlusPadding;

////////////////////////////////////////////////////////////////////////////////
// Pivot position
Expand All @@ -57,23 +53,64 @@ _x += string_width(_text) + _padding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, PEd_oPivot.x);
if (!is_undefined(_input))
{
PEd_oPivot.x = _input;
}
_x += _inputWidth + _padding;
_x += _inputWidthPlusPadding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, PEd_oPivot.y);
if (!is_undefined(_input))
{
PEd_oPivot.y = _input;
}
_x += _inputWidth + _padding;
_x += _inputWidthPlusPadding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, PEd_oPivot.z);
if (!is_undefined(_input))
{
PEd_oPivot.z = _input;
_x += _inputWidthPlusPadding;

////////////////////////////////////////////////////////////////////////////////
// Camera
_text = "Camera:";
draw_text(_x, _textY, _text);
_x += string_width(_text) + _padding;

if (global.pedUsing3D)
{
_input = PEd_guiDrawInput(_x, _y, _inputWidth, x);
if (!is_undefined(_input))
x = _input;
_x += _inputWidthPlusPadding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, y);
if (!is_undefined(_input))
y = _input;
_x += _inputWidthPlusPadding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, z);
if (!is_undefined(_input))
z = _input;
_x += _inputWidthPlusPadding;
}
else
{
_input = PEd_guiDrawInput(_x, _y, _inputWidth, view_xview[0]);
if (!is_undefined(_input))
view_xview[0] = _input;
_x += _inputWidthPlusPadding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, view_yview[0]);
if (!is_undefined(_input))
view_yview[0] = _input;
_x += _inputWidthPlusPadding;
}
_x += _inputWidth + _padding;

////////////////////////////////////////////////////////////////////////////////
// Camera speed
_text = "CamSpeed:";
draw_text(_x, _textY, _text);
_x += string_width(_text) + _padding;

_input = PEd_guiDrawInput(_x, _y, _inputWidth, camSpeed);
if (!is_undefined(_input))
camSpeed = _input;
_x += _inputWidthPlusPadding;

return PEd_vec2(_x + _padding, _containerHeight);

0 comments on commit b0f5f18

Please sign in to comment.