Skip to content

Commit

Permalink
Merge branch 'master' of ssh://git.redspell.ru/home/redspell/git/ligh…
Browse files Browse the repository at this point in the history
…tning
  • Loading branch information
serp256 committed Sep 18, 2012
2 parents e65f037 + defc6a8 commit 2ab9996
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
14 changes: 10 additions & 4 deletions src/Lightning.ml
Expand Up @@ -48,21 +48,27 @@ type stage_constructor = float -> float -> Stage.c;
(* value _stage: ref (option (float -> float -> stage eventTypeDisplayObject eventEmptyData)) = ref None; *)

IFDEF PC THEN
value init s =
value init s =
let s = (s :> stage_constructor) in
Pc_run.run s;
Pc_run.run s;

ELSE

value _stage : ref (option stage_constructor) = ref None;

value init s =
let s = (s :> stage_constructor) in
_stage.val := Some s;
_stage.val := Some s;

value stage_create width height =
match _stage.val with
[ None -> failwith "Stage not initialized"
| Some stage -> stage width height
| Some stage ->
let s = stage width height in
(
Stage.instance.val := Some s;
s;
)
];

IFDEF ANDROID THEN (* for link mlwrapper_android *)
Expand Down
16 changes: 11 additions & 5 deletions src/Stage.ml
Expand Up @@ -51,6 +51,7 @@ exception Touch_not_found;

value _screenSize = ref (0.,0.);
value screenSize () = !_screenSize;
value instance = ref None;

value onBackground = ref None;
value on_background () =
Expand All @@ -59,7 +60,12 @@ value on_background () =
match !onBackground with
[ Some f -> f()
| None -> ()
]
];

match !instance with
[ Some s -> s#cancelAllTouches ()
| _ -> ()
];
);
Callback.register "on_background" on_background;

Expand Down Expand Up @@ -154,18 +160,18 @@ class virtual c (_width:float) (_height:float) =
end touches
in
let otherTouches = !cTouches in
let () = debug:touches "Length of other touches: %d" (List.length otherTouches) in
(* let () = debug:touches "Length of other touches: %d" (List.length otherTouches) in *)
(
List.iter (fun (_,tch) -> tch.n_phase := TouchPhaseStationary) otherTouches;
let () = debug:touches
(* let () = debug:touches
List.iter begin fun (target,touch) ->
debug:touches "touch: %ld %f [%f:%f], [%F:%F], %d, %s, [ %s ]\n%!" touch.n_tid
touch.n_timestamp touch.n_globalX touch.n_globalY
touch.n_previousGlobalX touch.n_previousGlobalY
touch.n_tapCount (string_of_touchPhase touch.n_phase)
target#name
end (processedTouches @ otherTouches)
in
in *)
(* группируем их по таргетам и вперед - incorrect *)
let fireTouches = List.fold_left (fun res (target,touch) -> MList.add_assoc target (Touch.t_of_n touch) res) [] processedTouches in
let fireTouches =
Expand Down Expand Up @@ -270,4 +276,4 @@ class virtual c (_width:float) (_height:float) =

initializer Timers.init 0.;

end;
end;
2 changes: 2 additions & 0 deletions src/Stage.mli
Expand Up @@ -46,3 +46,5 @@ class virtual c: [ float ] -> [ float ] ->
method onUnload: unit -> unit;
method dispatchBackPressedEv : unit -> bool;
end;

value instance: ref (option c);
3 changes: 2 additions & 1 deletion src/ios/mlwrapper_ios.m
Expand Up @@ -13,7 +13,7 @@


void process_touches(UIView *view, NSSet* touches, UIEvent *event, mlstage *mlstage) {
PRINT_DEBUG("process touched");
PRINT_DEBUG("process touched %d", [touches count]);
caml_acquire_runtime_system();
value mltouch = 1,mltouches = 1,globalX = 1,globalY = 1,time = 1, lst_el = 1;
Begin_roots5(mltouch,time,globalX,globalY,mltouches);
Expand Down Expand Up @@ -49,6 +49,7 @@ void process_touches(UIView *view, NSSet* touches, UIEvent *event, mlstage *mls
}
End_roots();
caml_release_runtime_system();
PRINT_DEBUG("process touches end");
}


Expand Down

0 comments on commit 2ab9996

Please sign in to comment.