mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 06:03:09 +00:00
-Fixed viewport stretch bugs
-Fixed input in viewport stretch bugs -Fixed tilemap pixel overlap (really?)
This commit is contained in:
parent
b8593c6f3f
commit
0360b454a4
@ -9,10 +9,16 @@ name_es="Plataformero"
|
||||
|
||||
width=800
|
||||
height=480
|
||||
stretch_2d=true
|
||||
stretch_2d=false
|
||||
stretch_mode="viewport"
|
||||
stretch_aspect="keep"
|
||||
|
||||
[image_loader]
|
||||
|
||||
filter=false
|
||||
gen_mipmaps=false
|
||||
repeat=false
|
||||
|
||||
[input]
|
||||
|
||||
move_left=[key(Left), jbutton(0, 14)]
|
||||
|
@ -56,7 +56,8 @@ abstract public class ConsumeTask {
|
||||
|
||||
protected void onPostExecute(String param){
|
||||
if(param == null){
|
||||
success();
|
||||
|
||||
success(new PaymentsCache(context).getConsumableValue("ticket", sku));
|
||||
}else{
|
||||
error(param);
|
||||
}
|
||||
@ -65,7 +66,7 @@ abstract public class ConsumeTask {
|
||||
}.execute();
|
||||
}
|
||||
|
||||
abstract protected void success();
|
||||
abstract protected void success(String ticket);
|
||||
abstract protected void error(String message);
|
||||
|
||||
}
|
||||
|
@ -28,11 +28,12 @@ abstract public class HandlePurchaseTask {
|
||||
|
||||
|
||||
public void handlePurchaseRequest(int resultCode, Intent data){
|
||||
// Log.d("XXX", "Handling purchase response");
|
||||
Log.d("XXX", "Handling purchase response");
|
||||
// int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
|
||||
PaymentsCache pc = new PaymentsCache(context);
|
||||
|
||||
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
|
||||
Log.d("XXX", "Purchase data:" + purchaseData);
|
||||
// String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
|
||||
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
@ -61,7 +62,7 @@ abstract public class HandlePurchaseTask {
|
||||
pc.setConsumableFlag("block", productId, true);
|
||||
pc.setConsumableValue("token", productId, purchaseToken);
|
||||
|
||||
success(purchaseData);
|
||||
success(productId);
|
||||
return;
|
||||
} catch (JSONException e) {
|
||||
error(e.getMessage());
|
||||
|
@ -84,8 +84,25 @@ public class PaymentsManager {
|
||||
new HandlePurchaseTask(activity){
|
||||
|
||||
@Override
|
||||
protected void success(String ticket) {
|
||||
godotPaymentV3.callbackSuccess(ticket);
|
||||
protected void success(final String sku) {
|
||||
new ConsumeTask(mService, activity) {
|
||||
|
||||
@Override
|
||||
protected void success(String ticket) {
|
||||
// godotPaymentV3.callbackSuccess("");
|
||||
godotPaymentV3.callbackSuccess(ticket);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void error(String message) {
|
||||
godotPaymentV3.callbackFail();
|
||||
|
||||
}
|
||||
}.consume(sku);
|
||||
|
||||
|
||||
|
||||
// godotPaymentV3.callbackSuccess(ticket);
|
||||
//validatePurchase(purchaseToken, sku);
|
||||
}
|
||||
|
||||
@ -99,7 +116,8 @@ public class PaymentsManager {
|
||||
protected void canceled() {
|
||||
godotPaymentV3.callbackCancel();
|
||||
|
||||
}}.handlePurchaseRequest(resultCode, data);
|
||||
}
|
||||
}.handlePurchaseRequest(resultCode, data);
|
||||
}
|
||||
|
||||
public void validatePurchase(String purchaseToken, final String sku){
|
||||
@ -112,8 +130,8 @@ public class PaymentsManager {
|
||||
new ConsumeTask(mService, activity) {
|
||||
|
||||
@Override
|
||||
protected void success() {
|
||||
godotPaymentV3.callbackSuccess("");
|
||||
protected void success(String ticket) {
|
||||
godotPaymentV3.callbackSuccess(ticket);
|
||||
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ abstract public class PurchaseTask {
|
||||
private boolean isLooping = false;
|
||||
|
||||
public void purchase(final String sku){
|
||||
// Log.d("XXX", "Starting purchase");
|
||||
Log.d("XXX", "Starting purchase for: " + sku);
|
||||
PaymentsCache pc = new PaymentsCache(context);
|
||||
Boolean isBlocked = pc.getConsumableFlag("block", sku);
|
||||
// if(isBlocked){
|
||||
@ -68,7 +68,7 @@ abstract public class PurchaseTask {
|
||||
new ConsumeTask(mService, context) {
|
||||
|
||||
@Override
|
||||
protected void success() {
|
||||
protected void success(String ticket) {
|
||||
// Log.d("XXX", "Product was erroniously purchased!");
|
||||
if(isLooping){
|
||||
// Log.d("XXX", "It is looping");
|
||||
|
@ -1647,6 +1647,13 @@ void OS_Windows::move_window_to_foreground() {
|
||||
|
||||
}
|
||||
|
||||
Error OS_Windows::shell_open(String p_uri) {
|
||||
|
||||
ShellExecuteW(NULL, L"open", p_uri.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
String OS_Windows::get_locale() const {
|
||||
|
||||
const _WinLocale *wl = &_win_locales[0];
|
||||
|
@ -246,6 +246,8 @@ public:
|
||||
virtual void make_rendering_thread();
|
||||
virtual void swap_buffers();
|
||||
|
||||
virtual Error shell_open(String p_uri);
|
||||
|
||||
void run();
|
||||
|
||||
virtual bool get_swap_ok_cancel() { return true; }
|
||||
|
@ -1015,6 +1015,11 @@ String OS_X11::get_name() {
|
||||
return "X11";
|
||||
}
|
||||
|
||||
Error OS_X11::shell_open(String p_uri) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void OS_X11::close_joystick(int p_id) {
|
||||
|
||||
|
@ -188,6 +188,7 @@ public:
|
||||
virtual void make_rendering_thread();
|
||||
virtual void swap_buffers();
|
||||
|
||||
virtual Error shell_open(String p_uri);
|
||||
|
||||
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
|
||||
virtual VideoMode get_video_mode(int p_screen=0) const;
|
||||
|
@ -585,8 +585,8 @@ TileMap::TileMap() {
|
||||
center_x=false;
|
||||
center_y=false;
|
||||
|
||||
fp_adjust=0.4;
|
||||
fp_adjust=0.4;
|
||||
fp_adjust=0.01;
|
||||
fp_adjust=0.01;
|
||||
}
|
||||
|
||||
TileMap::~TileMap() {
|
||||
|
@ -645,19 +645,6 @@ void Control::_notification(int p_notification) {
|
||||
}
|
||||
|
||||
|
||||
Size2 Control::_window_get_pos() const {
|
||||
|
||||
if (data.viewport) {
|
||||
|
||||
Rect2 r = data.viewport->get_visible_rect();
|
||||
return r.pos;
|
||||
} else
|
||||
return Point2();
|
||||
|
||||
//return get_global_transform().get_origin();
|
||||
}
|
||||
|
||||
|
||||
bool Control::clips_input() const {
|
||||
|
||||
return false;
|
||||
@ -956,12 +943,11 @@ void Control::_window_input_event(InputEvent p_event) {
|
||||
window->key_event_accepted=false;
|
||||
|
||||
Point2 mpos =(get_canvas_transform()).affine_inverse().xform(Point2(p_event.mouse_button.x,p_event.mouse_button.y));
|
||||
|
||||
if (p_event.mouse_button.pressed) {
|
||||
|
||||
|
||||
|
||||
Size2 pos = mpos - _window_get_pos();
|
||||
Size2 pos = mpos;
|
||||
if (window->mouse_focus && p_event.mouse_button.button_index!=window->mouse_focus_button) {
|
||||
|
||||
//do not steal mouse focus and stuff
|
||||
@ -1062,7 +1048,7 @@ void Control::_window_input_event(InputEvent p_event) {
|
||||
|
||||
if (window->mouse_over && window->drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
|
||||
|
||||
Size2 pos = mpos - _window_get_pos();
|
||||
Size2 pos = mpos;
|
||||
pos = window->focus_inv_xform.xform(pos);
|
||||
window->mouse_over->drop_data(pos,window->drag_data);
|
||||
window->drag_data=Variant();
|
||||
@ -1072,7 +1058,7 @@ void Control::_window_input_event(InputEvent p_event) {
|
||||
break;
|
||||
}
|
||||
|
||||
Size2 pos = mpos - _window_get_pos();
|
||||
Size2 pos = mpos;
|
||||
p_event.mouse_button.global_x = pos.x;
|
||||
p_event.mouse_button.global_y = pos.y;
|
||||
pos = window->focus_inv_xform.xform(pos);
|
||||
@ -1103,7 +1089,7 @@ void Control::_window_input_event(InputEvent p_event) {
|
||||
window->key_event_accepted=false;
|
||||
|
||||
Matrix32 localizer = (get_canvas_transform()).affine_inverse();
|
||||
Size2 pos = localizer.xform(Size2(p_event.mouse_motion.x,p_event.mouse_motion.y)) - _window_get_pos();
|
||||
Size2 pos = localizer.xform(Size2(p_event.mouse_motion.x,p_event.mouse_motion.y));
|
||||
Vector2 speed = localizer.basis_xform(Point2(p_event.mouse_motion.speed_x,p_event.mouse_motion.speed_y));
|
||||
Vector2 rel = localizer.basis_xform(Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y));
|
||||
|
||||
|
@ -193,7 +193,6 @@ private:
|
||||
|
||||
float _get_parent_range(int p_idx) const;
|
||||
float _get_range(int p_idx) const;
|
||||
Point2 _window_get_pos() const;
|
||||
float _s2a(float p_val, AnchorType p_anchor,float p_range) const;
|
||||
float _a2s(float p_val, AnchorType p_anchor,float p_range) const;
|
||||
void _modal_stack_remove();
|
||||
|
@ -940,7 +940,6 @@ void SceneMainLoop::_update_root_rect() {
|
||||
} break;
|
||||
case STRETCH_MODE_VIEWPORT: {
|
||||
|
||||
print_line("VP SIZE: "+viewport_size);
|
||||
root->set_rect(Rect2(Point2(),viewport_size));
|
||||
root->set_size_override_stretch(false);
|
||||
root->set_size_override(false,Size2());
|
||||
|
@ -764,13 +764,30 @@ bool Viewport::get_render_target_vflip() const{
|
||||
}
|
||||
|
||||
|
||||
Matrix32 Viewport::_get_input_pre_xform() const {
|
||||
|
||||
Matrix32 pre_xf;
|
||||
if (render_target) {
|
||||
|
||||
ERR_FAIL_COND_V(to_screen_rect.size.x==0,pre_xf);
|
||||
ERR_FAIL_COND_V(to_screen_rect.size.y==0,pre_xf);
|
||||
pre_xf.scale(rect.size/to_screen_rect.size);
|
||||
pre_xf.elements[2]=-to_screen_rect.pos;
|
||||
} else {
|
||||
|
||||
pre_xf.elements[2]=-rect.pos;
|
||||
}
|
||||
|
||||
return pre_xf;
|
||||
}
|
||||
|
||||
void Viewport::_make_input_local(InputEvent& ev) {
|
||||
|
||||
switch(ev.type) {
|
||||
|
||||
case InputEvent::MOUSE_BUTTON: {
|
||||
|
||||
Matrix32 ai = get_final_transform().affine_inverse();
|
||||
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
|
||||
Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
|
||||
Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y));
|
||||
ev.mouse_button.x=l.x;
|
||||
@ -781,7 +798,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
|
||||
} break;
|
||||
case InputEvent::MOUSE_MOTION: {
|
||||
|
||||
Matrix32 ai = get_final_transform().affine_inverse();
|
||||
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
|
||||
Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
|
||||
Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
|
||||
Vector2 r = ai.xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
|
||||
@ -795,7 +812,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
|
||||
} break;
|
||||
case InputEvent::SCREEN_TOUCH: {
|
||||
|
||||
Matrix32 ai = get_final_transform().affine_inverse();
|
||||
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
|
||||
Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y));
|
||||
ev.screen_touch.x=t.x;
|
||||
ev.screen_touch.y=t.y;
|
||||
@ -803,7 +820,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
|
||||
} break;
|
||||
case InputEvent::SCREEN_DRAG: {
|
||||
|
||||
Matrix32 ai = get_final_transform().affine_inverse();
|
||||
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
|
||||
Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y));
|
||||
Vector2 r = ai.xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
|
||||
Vector2 s = ai.xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
|
||||
@ -821,13 +838,13 @@ void Viewport::_make_input_local(InputEvent& ev) {
|
||||
|
||||
void Viewport::_vp_input(const InputEvent& p_ev) {
|
||||
|
||||
if (render_target)
|
||||
if (render_target && to_screen_rect==Rect2())
|
||||
return; //if render target, can't get input events
|
||||
|
||||
//this one handles system input, p_ev are in system coordinates
|
||||
//they are converted to viewport coordinates
|
||||
|
||||
InputEvent ev = p_ev;
|
||||
InputEvent ev = p_ev;
|
||||
_make_input_local(ev);
|
||||
input(ev);
|
||||
|
||||
|
@ -146,6 +146,7 @@ friend class RenderTargetTexture;
|
||||
|
||||
void update_worlds();
|
||||
|
||||
_FORCE_INLINE_ Matrix32 _get_input_pre_xform() const;
|
||||
|
||||
void _vp_enter_scene();
|
||||
void _vp_exit_scene();
|
||||
|
Loading…
Reference in New Issue
Block a user