Skip to content

Commit

Permalink
大雅久不作,吾衰竟谁陈
Browse files Browse the repository at this point in the history
修正输入和战斗后走路的错误
  • Loading branch information
scarsty committed Jul 15, 2024
1 parent 84d307f commit add3a31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
7 changes: 5 additions & 2 deletions src/InputBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ InputBox::InputBox()
{
}

InputBox::InputBox(const std::string& title, int font_size) : title_(title)
InputBox::InputBox(const std::string& title, int font_size) :
title_(title)
{
font_size_ = font_size;
}
Expand Down Expand Up @@ -42,10 +43,12 @@ void InputBox::dealEvent(BP_Event& e)
{
if (text_.size() >= 1)
{
uint8_t c = text_.back();
text_.pop_back();
if (text_.size() >= 1 && uint8_t(text_.back()) >= 128)
if (c >= 128 && text_.size() >= 2 && uint8_t(text_.back()) >= 128)
{
text_.pop_back();
text_.pop_back();
}
}
}
Expand Down
29 changes: 16 additions & 13 deletions src/VirtualStick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,25 @@ void VirtualStick::dealEvent(BP_Event& e)
}
else
{
axis_x_ = x;
axis_y_ = y;
double r = sqrt((x - axis_center_x_) * (x - axis_center_x_) + (y - axis_center_y_) * (y - axis_center_y_));
//fmt1::print("{}", r);
auto& intval = button_interval_[b];
if (r < axis_radius_ * 1.5)
if (b->getVisible())
{
engine->setGameControllerAxis(SDL_CONTROLLER_AXIS_LEFTX, (x - axis_center_x_) * 30000 / axis_radius_);
engine->setGameControllerAxis(SDL_CONTROLLER_AXIS_LEFTY, (y - axis_center_y_) * 30000 / axis_radius_);
button_interval_[b].prev_press = engine->getTicks();
is_press = true;
b->state_ = NodePress;
intval.interval = 0;
if (is_real)
axis_x_ = x;
axis_y_ = y;
double r = sqrt((x - axis_center_x_) * (x - axis_center_x_) + (y - axis_center_y_) * (y - axis_center_y_));
//fmt1::print("{}", r);
auto& intval = button_interval_[b];
if (r < axis_radius_ * 1.5)
{
engine->setGameControllerAxis(SDL_CONTROLLER_AXIS_LEFTX, (x - axis_center_x_) * 30000 / axis_radius_);
engine->setGameControllerAxis(SDL_CONTROLLER_AXIS_LEFTY, (y - axis_center_y_) * 30000 / axis_radius_);
button_interval_[b].prev_press = engine->getTicks();
is_press = true;
b->state_ = NodePress;
intval.interval = 0;
if (is_real)
{
intval.interval = 0;
}
}
}
}
Expand Down

0 comments on commit add3a31

Please sign in to comment.