mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-07-11 11:20:05 +00:00
chore: format Minecraft.Client
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "../Platform/stdafx.h"
|
||||
#include "ConsoleInput.h"
|
||||
|
||||
ConsoleInput::ConsoleInput(const std::wstring& msg, ConsoleInputSource *source)
|
||||
{
|
||||
this->msg = msg;
|
||||
this->source = source;
|
||||
ConsoleInput::ConsoleInput(const std::wstring& msg,
|
||||
ConsoleInputSource* source) {
|
||||
this->msg = msg;
|
||||
this->source = source;
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
#include "ConsoleInputSource.h"
|
||||
|
||||
|
||||
class ConsoleInput
|
||||
{
|
||||
class ConsoleInput {
|
||||
public:
|
||||
std::wstring msg;
|
||||
ConsoleInputSource *source;
|
||||
std::wstring msg;
|
||||
ConsoleInputSource* source;
|
||||
|
||||
ConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
|
||||
ConsoleInput(const std::wstring& msg, ConsoleInputSource* source);
|
||||
};
|
||||
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
class ConsoleInputSource
|
||||
{
|
||||
class ConsoleInputSource {
|
||||
public:
|
||||
virtual ~ConsoleInputSource(){}
|
||||
virtual void info(const std::wstring& string) = 0;
|
||||
virtual ~ConsoleInputSource() {}
|
||||
virtual void info(const std::wstring& string) = 0;
|
||||
virtual void warn(const std::wstring& string) = 0;
|
||||
virtual std::wstring getConsoleName() = 0;
|
||||
};
|
||||
|
||||
@@ -8,108 +8,123 @@
|
||||
#include "../Player/LocalPlayer.h"
|
||||
#include "../GameState/Options.h"
|
||||
|
||||
Input::Input()
|
||||
{
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
wasJumping = false;
|
||||
jumping = false;
|
||||
sneaking = false;
|
||||
sprintKey = false;
|
||||
Input::Input() {
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
wasJumping = false;
|
||||
jumping = false;
|
||||
sneaking = false;
|
||||
sprintKey = false;
|
||||
|
||||
lReset = false;
|
||||
lReset = false;
|
||||
rReset = false;
|
||||
}
|
||||
|
||||
void Input::tick(LocalPlayer *player)
|
||||
{
|
||||
// 4J Stu - Assume that we only need one input class, even though the java has subclasses for keyboard/controller
|
||||
// This function is based on the ControllerInput class in the Java, and will probably need changed
|
||||
//OutputDebugString("INPUT: Beginning input tick\n");
|
||||
void Input::tick(LocalPlayer* player) {
|
||||
// 4J Stu - Assume that we only need one input class, even though the java
|
||||
// has subclasses for keyboard/controller This function is based on the
|
||||
// ControllerInput class in the Java, and will probably need changed
|
||||
// OutputDebugString("INPUT: Beginning input tick\n");
|
||||
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
int iPad=player->GetXboxPad();
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
int iPad = player->GetXboxPad();
|
||||
|
||||
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
|
||||
xa = -InputManager.GetJoypadStick_LX(iPad);
|
||||
else
|
||||
xa = 0.0f;
|
||||
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_FORWARD) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_BACKWARD) )
|
||||
ya = InputManager.GetJoypadStick_LY(iPad);
|
||||
else
|
||||
ya = 0.0f;
|
||||
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LEFT) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_RIGHT))
|
||||
xa = -InputManager.GetJoypadStick_LX(iPad);
|
||||
else
|
||||
xa = 0.0f;
|
||||
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_FORWARD) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_BACKWARD))
|
||||
ya = InputManager.GetJoypadStick_LY(iPad);
|
||||
else
|
||||
ya = 0.0f;
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (app.GetFreezePlayers())
|
||||
{
|
||||
xa = ya = 0.0f;
|
||||
player->abilities.flying = true;
|
||||
}
|
||||
if (app.GetFreezePlayers()) {
|
||||
xa = ya = 0.0f;
|
||||
player->abilities.flying = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!lReset)
|
||||
{
|
||||
if (xa*xa+ya*ya==0.0f)
|
||||
{
|
||||
|
||||
if (!lReset) {
|
||||
if (xa * xa + ya * ya == 0.0f) {
|
||||
lReset = true;
|
||||
}
|
||||
xa = ya = 0.0f;
|
||||
}
|
||||
|
||||
// 4J - in flying mode, don't actually toggle sneaking
|
||||
if(!player->abilities.flying)
|
||||
{
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE)) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE))
|
||||
{
|
||||
sneaking=!sneaking;
|
||||
}
|
||||
}
|
||||
// 4J - in flying mode, don't actually toggle sneaking
|
||||
if (!player->abilities.flying) {
|
||||
if ((player->ullButtonsPressed &
|
||||
(1LL << MINECRAFT_ACTION_SNEAK_TOGGLE)) &&
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_SNEAK_TOGGLE)) {
|
||||
sneaking = !sneaking;
|
||||
}
|
||||
}
|
||||
|
||||
if(sneaking)
|
||||
{
|
||||
xa*=0.3f;
|
||||
ya*=0.3f;
|
||||
}
|
||||
if (sneaking) {
|
||||
xa *= 0.3f;
|
||||
ya *= 0.3f;
|
||||
}
|
||||
|
||||
float turnSpeed = 50.0f;
|
||||
|
||||
float tx = 0.0f;
|
||||
float ty = 0.0f;
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_RIGHT) )
|
||||
tx = InputManager.GetJoypadStick_RX(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_UP) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_DOWN) )
|
||||
ty = InputManager.GetJoypadStick_RY(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
|
||||
|
||||
float tx = 0.0f;
|
||||
float ty = 0.0f;
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_LEFT) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_RIGHT))
|
||||
tx = InputManager.GetJoypadStick_RX(iPad) *
|
||||
(((float)app.GetGameSettings(iPad,
|
||||
eGameSetting_Sensitivity_InGame)) /
|
||||
100.0f); // apply sensitivity to look
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_UP) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_DOWN))
|
||||
ty = InputManager.GetJoypadStick_RY(iPad) *
|
||||
(((float)app.GetGameSettings(iPad,
|
||||
eGameSetting_Sensitivity_InGame)) /
|
||||
100.0f); // apply sensitivity to look
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (app.GetFreezePlayers()) tx = ty = 0.0f;
|
||||
if (app.GetFreezePlayers()) tx = ty = 0.0f;
|
||||
#endif
|
||||
|
||||
// 4J: WESTY : Invert look Y if required.
|
||||
if ( app.GetGameSettings(iPad,eGameSetting_ControlInvertLook) )
|
||||
{
|
||||
ty = -ty;
|
||||
}
|
||||
// 4J: WESTY : Invert look Y if required.
|
||||
if (app.GetGameSettings(iPad, eGameSetting_ControlInvertLook)) {
|
||||
ty = -ty;
|
||||
}
|
||||
|
||||
if (!rReset)
|
||||
{
|
||||
if (tx*tx+ty*ty==0.0f)
|
||||
{
|
||||
if (!rReset) {
|
||||
if (tx * tx + ty * ty == 0.0f) {
|
||||
rReset = true;
|
||||
}
|
||||
tx = ty = 0.0f;
|
||||
}
|
||||
player->interpolateTurn(tx * abs(tx) * turnSpeed, ty * abs(ty) * turnSpeed);
|
||||
|
||||
//jumping = controller.isButtonPressed(0);
|
||||
player->interpolateTurn(tx * abs(tx) * turnSpeed, ty * abs(ty) * turnSpeed);
|
||||
|
||||
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SPRINT);
|
||||
jumping = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
|
||||
// jumping = controller.isButtonPressed(0);
|
||||
|
||||
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) &&
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_SPRINT);
|
||||
jumping =
|
||||
InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) &&
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (app.GetFreezePlayers()) jumping = false;
|
||||
if (app.GetFreezePlayers()) jumping = false;
|
||||
#endif
|
||||
|
||||
//OutputDebugString("INPUT: End input tick\n");
|
||||
// OutputDebugString("INPUT: End input tick\n");
|
||||
}
|
||||
@@ -1,24 +1,22 @@
|
||||
#pragma once
|
||||
class Player;
|
||||
|
||||
class Input
|
||||
{
|
||||
class Input {
|
||||
public:
|
||||
float xa;
|
||||
float xa;
|
||||
float ya;
|
||||
|
||||
bool wasJumping;
|
||||
bool jumping;
|
||||
bool sneaking;
|
||||
bool sprintKey;
|
||||
|
||||
Input(); // 4J - added
|
||||
virtual ~Input(){}
|
||||
|
||||
virtual void tick(LocalPlayer *player);
|
||||
Input(); // 4J - added
|
||||
virtual ~Input() {}
|
||||
|
||||
virtual void tick(LocalPlayer* player);
|
||||
|
||||
private:
|
||||
|
||||
bool lReset;
|
||||
bool rReset;
|
||||
};
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "../Platform/stdafx.h"
|
||||
#include "KeyMapping.h"
|
||||
|
||||
KeyMapping::KeyMapping(const std::wstring& name, int key)
|
||||
{
|
||||
this->name = name;
|
||||
this->key = key;
|
||||
KeyMapping::KeyMapping(const std::wstring& name, int key) {
|
||||
this->name = name;
|
||||
this->key = key;
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// 4J Stu - Not updated to 1.8.2 as we don't use this
|
||||
class KeyMapping
|
||||
{
|
||||
class KeyMapping {
|
||||
public:
|
||||
std::wstring name;
|
||||
int key;
|
||||
KeyMapping(const std::wstring& name, int key);
|
||||
std::wstring name;
|
||||
int key;
|
||||
KeyMapping(const std::wstring& name, int key);
|
||||
};
|
||||
Reference in New Issue
Block a user