From 838da4571db0ddb82728ed88667d1dad454c9573 Mon Sep 17 00:00:00 2001 From: John McCardle Date: Sat, 3 Jan 2026 10:59:52 -0500 Subject: [PATCH] update tests: new scene API --- tests/benchmarks/benchmark_moving_entities.py | 8 +- tests/benchmarks/benchmark_suite.py | 34 +++--- tests/benchmarks/entity_scale_benchmark.py | 18 +-- tests/benchmarks/layer_performance_test.py | 48 ++++---- tests/benchmarks/stress_test_suite.py | 28 ++--- tests/benchmarks/tcod_fov_isolated.py | 8 +- tests/benchmarks/tcod_scale_test.py | 8 +- tests/demo/demo_main.py | 18 +-- tests/demo/perspective_patrol_demo.py | 12 +- tests/demo/screens/base.py | 2 +- tests/demo/screens/focus_system_demo.py | 8 +- tests/geometry_demo/geometry_main.py | 18 +-- tests/geometry_demo/screens/base.py | 2 +- tests/integration/astar_vs_dijkstra.py | 8 +- tests/integration/debug_visibility.py | 2 +- tests/integration/dijkstra_all_paths.py | 8 +- tests/integration/dijkstra_cycle_paths.py | 8 +- tests/integration/dijkstra_debug.py | 8 +- tests/integration/dijkstra_interactive.py | 8 +- .../dijkstra_interactive_enhanced.py | 8 +- tests/integration/dijkstra_test.py | 6 +- tests/integration/interactive_visibility.py | 8 +- .../simple_interactive_visibility.py | 6 +- tests/integration/simple_visibility_test.py | 2 +- tests/notes/test_exception_exit.py | 4 +- .../regression/issue_123_chunk_system_test.py | 4 +- .../regression/issue_146_fov_returns_none.py | 8 +- tests/regression/issue_147_grid_layers.py | 8 +- .../regression/issue_148_layer_dirty_flags.py | 12 +- tests/regression/issue_37_simple_test.py | 2 +- tests/regression/issue_37_test.py | 2 +- tests/regression/issue_76_test.py | 4 +- .../issue_79_color_properties_test.py | 4 +- .../issue_99_texture_font_properties_test.py | 4 +- tests/regression/issue_9_minimal_test.py | 6 +- .../issue_9_rendertexture_resize_test.py | 6 +- tests/regression/issue_9_test.py | 6 +- .../test_type_preservation_solution.py | 4 +- tests/unit/WORKING_automation_test_example.py | 6 +- tests/unit/api_createScene_test.py | 6 +- tests/unit/api_setScene_currentScene_test.py | 12 +- .../unit/automation_screenshot_test_simple.py | 4 +- tests/unit/benchmark_logging_test.py | 4 +- tests/unit/collection_find_test.py | 12 +- tests/unit/collection_list_methods_test.py | 20 ++-- tests/unit/debug_empty_paths.py | 6 +- tests/unit/debug_render_test.py | 8 +- tests/unit/generate_docs_screenshots.py | 28 ++--- tests/unit/generate_grid_screenshot.py | 8 +- tests/unit/generate_sprite_screenshot.py | 8 +- tests/unit/keypress_scene_validation_test.py | 18 +-- .../unit/screenshot_transparency_fix_test.py | 6 +- tests/unit/simple_screenshot_test.py | 6 +- tests/unit/simple_timer_screenshot_test.py | 6 +- tests/unit/test_animation_callback_simple.py | 8 +- tests/unit/test_animation_chaining.py | 8 +- tests/unit/test_animation_debug.py | 8 +- tests/unit/test_animation_immediate.py | 6 +- tests/unit/test_animation_property_locking.py | 20 ++-- tests/unit/test_animation_raii.py | 26 ++-- tests/unit/test_animation_removal.py | 8 +- tests/unit/test_astar.py | 6 +- tests/unit/test_audio_cleanup.py | 2 +- tests/unit/test_bounds_hit_testing.py | 20 ++-- tests/unit/test_builtin_context.py | 4 +- tests/unit/test_color_fix.py | 2 +- tests/unit/test_color_helpers.py | 2 +- tests/unit/test_color_operations.py | 6 +- tests/unit/test_color_setter_bug.py | 6 +- tests/unit/test_dijkstra_pathfinding.py | 6 +- tests/unit/test_empty_animation_manager.py | 4 +- tests/unit/test_entity_animation.py | 8 +- tests/unit/test_entity_collection_remove.py | 4 +- tests/unit/test_entity_constructor.py | 4 +- tests/unit/test_entity_fix.py | 8 +- tests/unit/test_entity_path_to.py | 2 +- tests/unit/test_entity_path_to_edge_cases.py | 2 +- tests/unit/test_exact_failure.py | 4 +- tests/unit/test_frame_clipping.py | 12 +- tests/unit/test_frame_clipping_advanced.py | 6 +- tests/unit/test_grid_background.py | 6 +- tests/unit/test_grid_cell_events.py | 16 +-- tests/unit/test_grid_children.py | 6 +- tests/unit/test_grid_creation.py | 2 +- tests/unit/test_grid_error.py | 2 +- tests/unit/test_grid_iteration.py | 10 +- tests/unit/test_headless_benchmark.py | 6 +- tests/unit/test_headless_click.py | 12 +- tests/unit/test_headless_detection.py | 6 +- tests/unit/test_headless_modes.py | 6 +- tests/unit/test_metrics.py | 6 +- tests/unit/test_mouse_enter_exit.py | 18 +-- tests/unit/test_no_arg_constructors.py | 2 +- tests/unit/test_on_move.py | 20 ++-- tests/unit/test_oneline_for.py | 4 +- tests/unit/test_parent_child_system.py | 32 ++--- tests/unit/test_path_colors.py | 6 +- tests/unit/test_pathfinding_integration.py | 2 +- tests/unit/test_profiler_quick.py | 6 +- tests/unit/test_properties_quick.py | 2 +- tests/unit/test_python_object_cache.py | 6 +- tests/unit/test_range_25_bug.py | 8 +- tests/unit/test_range_threshold.py | 4 +- tests/unit/test_scene_properties.py | 2 +- tests/unit/test_scene_transitions.py | 111 ++++++++++-------- tests/unit/test_scene_transitions_headless.py | 18 +-- tests/unit/test_simple_callback.py | 4 +- tests/unit/test_simple_drawable.py | 2 +- tests/unit/test_stdin_theory.py | 4 +- tests/unit/test_step_function.py | 4 +- tests/unit/test_synchronous_screenshot.py | 6 +- tests/unit/test_tcod_complete.py | 2 +- tests/unit/test_tcod_fov.py | 2 +- tests/unit/test_tcod_minimal.py | 2 +- tests/unit/test_tcod_pathfinding.py | 2 +- tests/unit/test_text_input.py | 8 +- tests/unit/test_timer_callback.py | 4 +- tests/unit/test_timer_legacy.py | 4 +- tests/unit/test_timer_object.py | 4 +- tests/unit/test_timer_once.py | 4 +- tests/unit/test_uiarc.py | 6 +- tests/unit/test_uicaption_visual.py | 8 +- tests/unit/test_uicircle.py | 6 +- tests/unit/test_utf8_encoding.py | 2 +- tests/unit/test_vector_arithmetic.py | 2 +- tests/unit/test_viewport_scaling.py | 10 +- tests/unit/test_visibility.py | 6 +- tests/unit/test_visual_path.py | 6 +- tests/unit/ui_Entity_issue73_test.py | 6 +- tests/unit/ui_Frame_test_detailed.py | 12 +- tests/unit/ui_Grid_none_texture_test.py | 8 +- tests/unit/ui_Grid_null_texture_test.py | 6 +- tests/unit/ui_Grid_test_no_grid.py | 6 +- tests/unit/ui_Sprite_issue19_test.py | 6 +- tests/unit/ui_UICollection_issue69_test.py | 6 +- tests/unit/validate_screenshot_test.py | 6 +- tests/unit/working_timer_test.py | 6 +- tests/vllm_demo/0_basic_vllm_demo.py | 6 +- tests/vllm_demo/1_multi_agent_demo.py | 6 +- tests/vllm_demo/2_integrated_demo.py | 6 +- tests/vllm_demo/3_multi_turn_demo.py | 6 +- tests/vllm_demo/4_enhanced_action_demo.py | 6 +- 142 files changed, 616 insertions(+), 601 deletions(-) diff --git a/tests/benchmarks/benchmark_moving_entities.py b/tests/benchmarks/benchmark_moving_entities.py index 23d79d6..c4c7b50 100644 --- a/tests/benchmarks/benchmark_moving_entities.py +++ b/tests/benchmarks/benchmark_moving_entities.py @@ -21,11 +21,11 @@ import sys import random # Create the benchmark scene -mcrfpy.createScene("benchmark") -mcrfpy.setScene("benchmark") +benchmark = mcrfpy.Scene("benchmark") +benchmark.activate() # Get scene UI -ui = mcrfpy.sceneUI("benchmark") +ui = benchmark.children # Create a 100x100 grid grid = mcrfpy.Grid( @@ -94,7 +94,7 @@ def handle_key(key, state): print("\nBenchmark ended by user") sys.exit(0) -mcrfpy.keypressScene(handle_key) +benchmark.on_key = handle_key # Update entity positions def update_entities(ms): diff --git a/tests/benchmarks/benchmark_suite.py b/tests/benchmarks/benchmark_suite.py index 72c24c7..9a8f2c7 100644 --- a/tests/benchmarks/benchmark_suite.py +++ b/tests/benchmarks/benchmark_suite.py @@ -158,14 +158,14 @@ def run_next_scenario(): def setup_empty_scene(): """Scenario 1: Empty scene - pure engine overhead.""" - mcrfpy.createScene("bench_empty") - mcrfpy.setScene("bench_empty") + bench_empty = mcrfpy.Scene("bench_empty") + bench_empty.activate() def setup_static_100(): """Scenario 2: 100 static frames - best case for caching.""" - mcrfpy.createScene("bench_static") - ui = mcrfpy.sceneUI("bench_static") + bench_static = mcrfpy.Scene("bench_static") + ui = bench_static.children # Create 100 frames in a 10x10 grid for i in range(100): @@ -183,13 +183,13 @@ def setup_static_100(): ui.append(frame) - mcrfpy.setScene("bench_static") + bench_static.activate() def setup_animated_100(): """Scenario 3: 100 frames all animating - worst case for caching.""" - mcrfpy.createScene("bench_animated") - ui = mcrfpy.sceneUI("bench_animated") + bench_animated = mcrfpy.Scene("bench_animated") + ui = bench_animated.children frames = [] for i in range(100): @@ -200,7 +200,7 @@ def setup_animated_100(): frames.append(frame) ui.append(frame) - mcrfpy.setScene("bench_animated") + bench_animated.activate() # Start animations on all frames (color animation = content change) for i, frame in enumerate(frames): @@ -212,8 +212,8 @@ def setup_animated_100(): def setup_mixed_100(): """Scenario 4: 100 frames, only 10 animating - realistic case.""" - mcrfpy.createScene("bench_mixed") - ui = mcrfpy.sceneUI("bench_mixed") + bench_mixed = mcrfpy.Scene("bench_mixed") + ui = bench_mixed.children frames = [] for i in range(100): @@ -224,7 +224,7 @@ def setup_mixed_100(): frames.append(frame) ui.append(frame) - mcrfpy.setScene("bench_mixed") + bench_mixed.activate() # Animate only 10 frames (every 10th) for i in range(0, 100, 10): @@ -235,8 +235,8 @@ def setup_mixed_100(): def setup_deep_hierarchy(): """Scenario 5: 5 levels of nesting - test dirty flag propagation cost.""" - mcrfpy.createScene("bench_deep") - ui = mcrfpy.sceneUI("bench_deep") + bench_deep = mcrfpy.Scene("bench_deep") + ui = bench_deep.children # Create 10 trees, each with 5 levels of nesting deepest_frames = [] @@ -263,7 +263,7 @@ def setup_deep_hierarchy(): if level == 4: # Deepest level deepest_frames.append(frame) - mcrfpy.setScene("bench_deep") + bench_deep.activate() # Animate the deepest frames - tests propagation up the hierarchy for frame in deepest_frames: @@ -273,8 +273,8 @@ def setup_deep_hierarchy(): def setup_grid_stress(): """Scenario 6: Large grid with entities - known performance bottleneck.""" - mcrfpy.createScene("bench_grid") - ui = mcrfpy.sceneUI("bench_grid") + bench_grid = mcrfpy.Scene("bench_grid") + ui = bench_grid.children # Create a 50x50 grid (2500 cells) grid = mcrfpy.Grid(grid_size=(50, 50), pos=(50, 50), size=(700, 700)) @@ -303,7 +303,7 @@ def setup_grid_stress(): except Exception as e: print(f" Note: Could not create entities: {e}") - mcrfpy.setScene("bench_grid") + bench_grid.activate() # ============================================================================ diff --git a/tests/benchmarks/entity_scale_benchmark.py b/tests/benchmarks/entity_scale_benchmark.py index 07d562a..74fa472 100644 --- a/tests/benchmarks/entity_scale_benchmark.py +++ b/tests/benchmarks/entity_scale_benchmark.py @@ -24,13 +24,14 @@ import random # Configuration # Use smaller grid for denser entity distribution (more realistic visibility tests) -GRID_SIZE = (100, 100) # 10,000 cells - entities will actually see each other +#GRID_SIZE = (100, 100) # 10,000 cells - entities will actually see each other +GRID_SIZE = (1250, 1250) # Full suite - may timeout on large counts due to O(n²) visibility # ENTITY_COUNTS = [100, 500, 1000, 2500, 5000, 10000] # Extended suite to validate scalability (on 100x100 grid) -ENTITY_COUNTS = [100, 500, 1000, 2000, 5000] +ENTITY_COUNTS = [100, 500, 1000, 5000] QUERY_RADIUS = 15 # Smaller radius for smaller grid MOVEMENT_PERCENT = 0.10 # 10% of entities move each frame N2N_SAMPLE_SIZE = 50 # Sample size for N×N visibility test @@ -44,11 +45,12 @@ def setup_grid_with_entities(n_entities): global texture scene_name = f"bench_{n_entities}" - mcrfpy.createScene(scene_name) - ui = mcrfpy.sceneUI(scene_name) + _scene = mcrfpy.Scene(scene_name) + ui = _scene.children # Create grid - minimal rendering size since we're testing entity operations - grid = mcrfpy.Grid(grid_size=GRID_SIZE, pos=(0, 0), size=(100, 100)) + #grid = mcrfpy.Grid(grid_size=GRID_SIZE, pos=(0, 0), size=(100, 100)) + grid = mcrfpy.Grid(grid_size=GRID_SIZE, pos=(0, 0), size=(1024, 768)) ui.append(grid) # Load texture once @@ -66,7 +68,7 @@ def setup_grid_with_entities(n_entities): entity = mcrfpy.Entity((x, y), texture, 0, grid) grid.entities.append(entity) - mcrfpy.setScene(scene_name) + mcrfpy.current_scene = scene_name return grid, scene_name @@ -75,8 +77,8 @@ def benchmark_creation(n_entities): global texture scene_name = "bench_create_test" - mcrfpy.createScene(scene_name) - ui = mcrfpy.sceneUI(scene_name) + _scene = mcrfpy.Scene(scene_name) + ui = _scene.children grid = mcrfpy.Grid(grid_size=GRID_SIZE, pos=(0, 0), size=(100, 100)) ui.append(grid) diff --git a/tests/benchmarks/layer_performance_test.py b/tests/benchmarks/layer_performance_test.py index 6649a6b..b62844b 100644 --- a/tests/benchmarks/layer_performance_test.py +++ b/tests/benchmarks/layer_performance_test.py @@ -99,8 +99,8 @@ def run_next_test(): def setup_base_layer_static(): """ColorLayer with per-cell set() calls - static after initial fill.""" - mcrfpy.createScene("test_base_static") - ui = mcrfpy.sceneUI("test_base_static") + test_base_static = mcrfpy.Scene("test_base_static") + ui = test_base_static.children grid = mcrfpy.Grid(grid_size=(GRID_SIZE, GRID_SIZE), pos=(10, 10), size=(600, 600)) @@ -112,13 +112,13 @@ def setup_base_layer_static(): for x in range(GRID_SIZE): layer.set(x, y, mcrfpy.Color((x * 2) % 256, (y * 2) % 256, 128, 255)) - mcrfpy.setScene("test_base_static") + test_base_static.activate() def setup_base_layer_modified(): """ColorLayer with single cell modified each frame - tests dirty flag.""" - mcrfpy.createScene("test_base_mod") - ui = mcrfpy.sceneUI("test_base_mod") + test_base_mod = mcrfpy.Scene("test_base_mod") + ui = test_base_mod.children grid = mcrfpy.Grid(grid_size=(GRID_SIZE, GRID_SIZE), pos=(10, 10), size=(600, 600)) @@ -136,14 +136,14 @@ def setup_base_layer_modified(): layer.set(x, y, mcrfpy.Color(255, 0, 0, 255)) mod_counter[0] += 1 - mcrfpy.setScene("test_base_mod") + test_base_mod.activate() mcrfpy.setTimer("modify", modify_cell, 1) def setup_color_layer_static(): """New ColorLayer with dirty flag caching - static after fill.""" - mcrfpy.createScene("test_color_static") - ui = mcrfpy.sceneUI("test_color_static") + test_color_static = mcrfpy.Scene("test_color_static") + ui = test_color_static.children grid = mcrfpy.Grid(grid_size=(GRID_SIZE, GRID_SIZE), pos=(10, 10), size=(600, 600)) @@ -153,13 +153,13 @@ def setup_color_layer_static(): layer = grid.add_layer("color", z_index=-1) layer.fill(mcrfpy.Color(100, 150, 200, 128)) - mcrfpy.setScene("test_color_static") + test_color_static.activate() def setup_color_layer_modified(): """ColorLayer with single cell modified each frame - tests dirty flag.""" - mcrfpy.createScene("test_color_mod") - ui = mcrfpy.sceneUI("test_color_mod") + test_color_mod = mcrfpy.Scene("test_color_mod") + ui = test_color_mod.children grid = mcrfpy.Grid(grid_size=(GRID_SIZE, GRID_SIZE), pos=(10, 10), size=(600, 600)) @@ -176,14 +176,14 @@ def setup_color_layer_modified(): layer.set(x, y, mcrfpy.Color(255, 0, 0, 255)) mod_counter[0] += 1 - mcrfpy.setScene("test_color_mod") + test_color_mod.activate() mcrfpy.setTimer("modify", modify_cell, 1) def setup_tile_layer_static(): """TileLayer with caching - static after fill.""" - mcrfpy.createScene("test_tile_static") - ui = mcrfpy.sceneUI("test_tile_static") + test_tile_static = mcrfpy.Scene("test_tile_static") + ui = test_tile_static.children try: texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) @@ -198,13 +198,13 @@ def setup_tile_layer_static(): layer = grid.add_layer("tile", z_index=-1, texture=texture) layer.fill(5) - mcrfpy.setScene("test_tile_static") + test_tile_static.activate() def setup_tile_layer_modified(): """TileLayer with single cell modified each frame.""" - mcrfpy.createScene("test_tile_mod") - ui = mcrfpy.sceneUI("test_tile_mod") + test_tile_mod = mcrfpy.Scene("test_tile_mod") + ui = test_tile_mod.children try: texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) @@ -229,14 +229,14 @@ def setup_tile_layer_modified(): layer.set(x, y, (mod_counter[0] % 20)) mod_counter[0] += 1 - mcrfpy.setScene("test_tile_mod") + test_tile_mod.activate() mcrfpy.setTimer("modify", modify_cell, 1) def setup_multi_layer_static(): """Multiple layers (5 color, 5 tile) - all static.""" - mcrfpy.createScene("test_multi_static") - ui = mcrfpy.sceneUI("test_multi_static") + test_multi_static = mcrfpy.Scene("test_multi_static") + ui = test_multi_static.children try: texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) @@ -259,13 +259,13 @@ def setup_multi_layer_static(): layer.fill(i * 4) print(f" Created {len(grid.layers)} layers") - mcrfpy.setScene("test_multi_static") + test_multi_static.activate() def setup_base_vs_layer_comparison(): """Direct comparison: same visual using base API vs layer API.""" - mcrfpy.createScene("test_comparison") - ui = mcrfpy.sceneUI("test_comparison") + test_comparison = mcrfpy.Scene("test_comparison") + ui = test_comparison.children # Grid using ONLY the new layer system (no base layer colors) grid = mcrfpy.Grid(grid_size=(GRID_SIZE, GRID_SIZE), @@ -280,7 +280,7 @@ def setup_base_vs_layer_comparison(): for x in range(GRID_SIZE): layer.set(x, y, mcrfpy.Color((x * 2) % 256, (y * 2) % 256, 128, 255)) - mcrfpy.setScene("test_comparison") + test_comparison.activate() # ============================================================================ diff --git a/tests/benchmarks/stress_test_suite.py b/tests/benchmarks/stress_test_suite.py index 598cd74..ba2546d 100644 --- a/tests/benchmarks/stress_test_suite.py +++ b/tests/benchmarks/stress_test_suite.py @@ -55,7 +55,7 @@ class StressTestRunner: # Setup scene scene_name = f"stress_{self.current_test}" - mcrfpy.createScene(scene_name) + _scene = mcrfpy.Scene(scene_name) # Start benchmark mcrfpy.start_benchmark() @@ -67,7 +67,7 @@ class StressTestRunner: except Exception as e: print(f" SETUP ERROR: {e}") - mcrfpy.setScene(scene_name) + mcrfpy.current_scene = scene_name self.frames_counted = 0 def end_current_test(self): @@ -133,10 +133,10 @@ class StressTestRunner: print("="*50) print(f"Tests: {len(self.tests)}, Duration: {TEST_DURATION_MS}ms each") - mcrfpy.createScene("init") - ui = mcrfpy.sceneUI("init") + init = mcrfpy.Scene("init") + ui = init.children ui.append(mcrfpy.Frame(pos=(0,0), size=(10,10))) # Required for timer to fire - mcrfpy.setScene("init") + init.activate() mcrfpy.setTimer("tick", self.tick, TIMER_INTERVAL_MS) @@ -146,7 +146,7 @@ class StressTestRunner: def test_many_frames(scene_name): """1000 Frame elements""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object for i in range(1000): frame = mcrfpy.Frame( pos=((i % 32) * 32, (i // 32) * 24), @@ -158,7 +158,7 @@ def test_many_frames(scene_name): def test_many_sprites(scene_name): """500 Sprite elements""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) for i in range(500): sprite = mcrfpy.Sprite( @@ -173,7 +173,7 @@ def test_many_sprites(scene_name): def test_many_captions(scene_name): """500 Caption elements""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object for i in range(500): caption = mcrfpy.Caption( text=f"Text #{i}", @@ -184,7 +184,7 @@ def test_many_captions(scene_name): def test_deep_nesting(scene_name): """15-level nested frames""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object current = ui for level in range(15): frame = mcrfpy.Frame( @@ -202,7 +202,7 @@ def test_deep_nesting(scene_name): def test_large_grid(scene_name): """100x100 grid with 500 entities""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) grid = mcrfpy.Grid(pos=(50, 50), size=(900, 650), grid_size=(100, 100), texture=texture) ui.append(grid) @@ -223,7 +223,7 @@ def test_large_grid(scene_name): def test_animation_stress(scene_name): """100 frames with 200 animations""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object for i in range(100): frame = mcrfpy.Frame( pos=((i % 10) * 100 + 10, (i // 10) * 70 + 10), @@ -241,7 +241,7 @@ def test_animation_stress(scene_name): def test_static_scene(scene_name): """Static game scene (ideal for caching)""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) # Background @@ -270,7 +270,7 @@ def test_static_scene(scene_name): def test_static_scene_cached(scene_name): """Static game scene with cache_subtree enabled (#144)""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) # Background with caching enabled @@ -299,7 +299,7 @@ def test_static_scene_cached(scene_name): def test_deep_nesting_cached(scene_name): """15-level nested frames with cache_subtree on outer frame (#144)""" - ui = mcrfpy.sceneUI(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object # Outer frame with caching - entire subtree cached outer = mcrfpy.Frame( diff --git a/tests/benchmarks/tcod_fov_isolated.py b/tests/benchmarks/tcod_fov_isolated.py index b15af17..ee491e3 100644 --- a/tests/benchmarks/tcod_fov_isolated.py +++ b/tests/benchmarks/tcod_fov_isolated.py @@ -12,8 +12,8 @@ def run_test(runtime): print("=" * 60) # Create a 1000x1000 grid - mcrfpy.createScene("test") - ui = mcrfpy.sceneUI("test") + test = mcrfpy.Scene("test") + ui = test.children texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) print("\nCreating 1000x1000 grid...") @@ -94,6 +94,6 @@ def run_test(runtime): sys.exit(0) -mcrfpy.createScene("init") -mcrfpy.setScene("init") +init = mcrfpy.Scene("init") +init.activate() mcrfpy.setTimer("test", run_test, 100) diff --git a/tests/benchmarks/tcod_scale_test.py b/tests/benchmarks/tcod_scale_test.py index cb5ff0e..6bb38da 100644 --- a/tests/benchmarks/tcod_scale_test.py +++ b/tests/benchmarks/tcod_scale_test.py @@ -19,8 +19,8 @@ def benchmark_grid_size(grid_x, grid_y): # Create scene and grid scene_name = f"bench_{grid_x}x{grid_y}" - mcrfpy.createScene(scene_name) - ui = mcrfpy.sceneUI(scene_name) + _scene = mcrfpy.Scene(scene_name) + ui = _scene.children # TODO: Replace _scene with correct Scene object texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) @@ -130,8 +130,8 @@ def main(): sys.exit(0) # Run immediately (no timer needed for this test) -mcrfpy.createScene("init") -mcrfpy.setScene("init") +init = mcrfpy.Scene("init") +init.activate() # Use a timer to let the engine initialize def run_benchmark(runtime): diff --git a/tests/demo/demo_main.py b/tests/demo/demo_main.py index 67bc94f..ceae6c2 100644 --- a/tests/demo/demo_main.py +++ b/tests/demo/demo_main.py @@ -65,8 +65,8 @@ class DemoRunner: def create_menu(self): """Create the main menu screen.""" - mcrfpy.createScene("menu") - ui = mcrfpy.sceneUI("menu") + menu = mcrfpy.Scene("menu") + ui = menu.children # Title title = mcrfpy.Caption(text="McRogueFace Demo", pos=(400, 30)) @@ -122,7 +122,7 @@ class DemoRunner: sys.exit(0) return screen = self.screens[self.current_index] - mcrfpy.setScene(screen.scene_name) + mcrfpy.current_scene = screen self.render_wait = 1 elif self.render_wait < 2: # Wait additional frame @@ -157,23 +157,23 @@ class DemoRunner: # ESC returns to menu elif key == "Escape": - mcrfpy.setScene("menu") + menu.activate() # Q quits elif key == "Q": sys.exit(0) # Register keyboard handler on menu scene - mcrfpy.setScene("menu") - mcrfpy.keypressScene(handle_key) + menu.activate() + menu.on_key = handle_key # Also register keyboard handler on all demo scenes for screen in self.screens: - mcrfpy.setScene(screen.scene_name) - mcrfpy.keypressScene(handle_key) + mcrfpy.current_scene = screen + menu.on_key = handle_key # Start on menu - mcrfpy.setScene("menu") + menu.activate() def main(): """Main entry point.""" diff --git a/tests/demo/perspective_patrol_demo.py b/tests/demo/perspective_patrol_demo.py index 9ca0bab..2bab026 100644 --- a/tests/demo/perspective_patrol_demo.py +++ b/tests/demo/perspective_patrol_demo.py @@ -37,10 +37,10 @@ def setup_scene(): """Create the demo scene""" global g_grid, g_patrol, g_fov_layer - mcrfpy.createScene("patrol_demo") - mcrfpy.setScene("patrol_demo") + patrol_demo = mcrfpy.Scene("patrol_demo") + patrol_demo.activate() - ui = mcrfpy.sceneUI("patrol_demo") + ui = patrol_demo.children # Title title = mcrfpy.Caption(text="Perspective Patrol Demo", pos=(10, 10)) @@ -123,7 +123,7 @@ def setup_scene(): ui.append(status) # Set up keyboard handler - mcrfpy.keypressScene(on_keypress) + patrol_demo.on_key = on_keypress # Start patrol timer mcrfpy.setTimer("patrol", patrol_step, move_timer_ms) @@ -173,7 +173,7 @@ def on_keypress(key, state): else: update_status("Status: Patrolling") elif key == "Q": - mcrfpy.setScene(None) + mcrfpy.current_scene = None def reset_vision(): """Reset entity's discovered state to demonstrate unknown vs discovered""" @@ -194,7 +194,7 @@ def reset_vision(): def update_status(text): """Update status caption""" - ui = mcrfpy.sceneUI("patrol_demo") + ui = patrol_demo.children for element in ui: if hasattr(element, 'name') and element.name == "status": element.text = text diff --git a/tests/demo/screens/base.py b/tests/demo/screens/base.py index 8e32206..82f4d79 100644 --- a/tests/demo/screens/base.py +++ b/tests/demo/screens/base.py @@ -9,7 +9,7 @@ class DemoScreen: def __init__(self, scene_name): self.scene_name = scene_name - mcrfpy.createScene(scene_name) + _scene = mcrfpy.Scene(scene_name) self.ui = mcrfpy.sceneUI(scene_name) def setup(self): diff --git a/tests/demo/screens/focus_system_demo.py b/tests/demo/screens/focus_system_demo.py index fc3ba88..4d8bd8f 100644 --- a/tests/demo/screens/focus_system_demo.py +++ b/tests/demo/screens/focus_system_demo.py @@ -600,8 +600,8 @@ def create_demo_scene(): """Create and populate the focus system demo scene.""" # Create scene - mcrfpy.createScene("focus_demo") - ui = mcrfpy.sceneUI("focus_demo") + focus_demo = mcrfpy.Scene("focus_demo") + ui = focus_demo.children # Background bg = mcrfpy.Frame( @@ -752,10 +752,10 @@ def create_demo_scene(): status_text.text = "No widget focused" # Activate scene first (keypressScene sets handler for CURRENT scene) - mcrfpy.setScene("focus_demo") + focus_demo.activate() # Register key handler for the now-current scene - mcrfpy.keypressScene(on_key) + focus_demo.on_key = on_key # Set initial focus focus_mgr.focus(0) diff --git a/tests/geometry_demo/geometry_main.py b/tests/geometry_demo/geometry_main.py index e0aaa4f..92c90ae 100644 --- a/tests/geometry_demo/geometry_main.py +++ b/tests/geometry_demo/geometry_main.py @@ -66,8 +66,8 @@ class GeometryDemoRunner: def create_menu(self): """Create the main menu screen.""" - mcrfpy.createScene("geo_menu") - ui = mcrfpy.sceneUI("geo_menu") + geo_menu = mcrfpy.Scene("geo_menu") + ui = geo_menu.children # Screen dimensions SCREEN_WIDTH = 1024 @@ -142,7 +142,7 @@ class GeometryDemoRunner: sys.exit(0) return screen = self.screens[self.current_index] - mcrfpy.setScene(screen.scene_name) + mcrfpy.current_scene = screen self.render_wait = 1 elif self.render_wait < 3: # Wait for animated demos to show initial state @@ -188,21 +188,21 @@ class GeometryDemoRunner: elif key == "Escape": for screen in self.screens: screen.cleanup() - mcrfpy.setScene("geo_menu") + geo_menu.activate() # Q quits elif key == "Q": sys.exit(0) # Register keyboard handler on all scenes - mcrfpy.setScene("geo_menu") - mcrfpy.keypressScene(handle_key) + geo_menu.activate() + geo_menu.on_key = handle_key for screen in self.screens: - mcrfpy.setScene(screen.scene_name) - mcrfpy.keypressScene(handle_key) + mcrfpy.current_scene = screen + geo_menu.on_key = handle_key - mcrfpy.setScene("geo_menu") + geo_menu.activate() def main(): diff --git a/tests/geometry_demo/screens/base.py b/tests/geometry_demo/screens/base.py index ae64303..992208e 100644 --- a/tests/geometry_demo/screens/base.py +++ b/tests/geometry_demo/screens/base.py @@ -35,7 +35,7 @@ class GeometryDemoScreen: def __init__(self, scene_name): self.scene_name = scene_name - mcrfpy.createScene(scene_name) + _scene = mcrfpy.Scene(scene_name) self.ui = mcrfpy.sceneUI(scene_name) self.timers = [] # Track timer names for cleanup self._timer_configs = [] # Store timer configs for restart diff --git a/tests/integration/astar_vs_dijkstra.py b/tests/integration/astar_vs_dijkstra.py index be75ea2..5f9e6ad 100644 --- a/tests/integration/astar_vs_dijkstra.py +++ b/tests/integration/astar_vs_dijkstra.py @@ -28,7 +28,7 @@ def create_map(): """Create a map with obstacles to show pathfinding differences""" global grid, color_layer - mcrfpy.createScene("pathfinding_comparison") + pathfinding_comparison = mcrfpy.Scene("pathfinding_comparison") # Create grid grid = mcrfpy.Grid(grid_x=30, grid_y=20) @@ -198,7 +198,7 @@ print("Dijkstra explores in all directions (good for multiple targets)") create_map() # Set up UI -ui = mcrfpy.sceneUI("pathfinding_comparison") +ui = pathfinding_comparison.children ui.append(grid) # Scale and position @@ -230,8 +230,8 @@ legend2.fill_color = mcrfpy.Color(150, 150, 150) ui.append(legend2) # Set scene and input -mcrfpy.setScene("pathfinding_comparison") -mcrfpy.keypressScene(handle_keypress) +pathfinding_comparison.activate() +pathfinding_comparison.on_key = handle_keypress # Show initial A* path show_astar() diff --git a/tests/integration/debug_visibility.py b/tests/integration/debug_visibility.py index 89a4ab7..075e1df 100644 --- a/tests/integration/debug_visibility.py +++ b/tests/integration/debug_visibility.py @@ -7,7 +7,7 @@ import sys print("Debug visibility...") # Create scene and grid -mcrfpy.createScene("debug") +debug = mcrfpy.Scene("debug") grid = mcrfpy.Grid(grid_x=5, grid_y=5) # Initialize grid diff --git a/tests/integration/dijkstra_all_paths.py b/tests/integration/dijkstra_all_paths.py index 79ce919..fcece2b 100644 --- a/tests/integration/dijkstra_all_paths.py +++ b/tests/integration/dijkstra_all_paths.py @@ -30,7 +30,7 @@ def create_map(): """Create the map with entities""" global grid, color_layer, entities, all_combinations - mcrfpy.createScene("dijkstra_all") + dijkstra_all = mcrfpy.Scene("dijkstra_all") # Create grid grid = mcrfpy.Grid(grid_x=14, grid_y=10) @@ -178,7 +178,7 @@ print() create_map() # Set up UI -ui = mcrfpy.sceneUI("dijkstra_all") +ui = dijkstra_all.children ui.append(grid) # Scale and position @@ -221,8 +221,8 @@ expected.fill_color = mcrfpy.Color(255, 150, 150) ui.append(expected) # Set scene first, then set up input handler -mcrfpy.setScene("dijkstra_all") -mcrfpy.keypressScene(handle_keypress) +dijkstra_all.activate() +dijkstra_all.on_key = handle_keypress # Show first combination show_combination(0) diff --git a/tests/integration/dijkstra_cycle_paths.py b/tests/integration/dijkstra_cycle_paths.py index 2f71862..5336e40 100644 --- a/tests/integration/dijkstra_cycle_paths.py +++ b/tests/integration/dijkstra_cycle_paths.py @@ -28,7 +28,7 @@ def create_map(): """Create the map with entities""" global grid, color_layer, entities - mcrfpy.createScene("dijkstra_cycle") + dijkstra_cycle = mcrfpy.Scene("dijkstra_cycle") # Create grid grid = mcrfpy.Grid(grid_x=14, grid_y=10) @@ -189,7 +189,7 @@ print() create_map() # Set up UI -ui = mcrfpy.sceneUI("dijkstra_cycle") +ui = dijkstra_cycle.children ui.append(grid) # Scale and position @@ -222,8 +222,8 @@ legend.fill_color = mcrfpy.Color(150, 150, 150) ui.append(legend) # Show first valid path -mcrfpy.setScene("dijkstra_cycle") -mcrfpy.keypressScene(handle_keypress) +dijkstra_cycle.activate() +dijkstra_cycle.on_key = handle_keypress # Display initial path if path_combinations: diff --git a/tests/integration/dijkstra_debug.py b/tests/integration/dijkstra_debug.py index 6538fae..5b9ee5d 100644 --- a/tests/integration/dijkstra_debug.py +++ b/tests/integration/dijkstra_debug.py @@ -27,7 +27,7 @@ def create_simple_map(): """Create a simple test map""" global grid, color_layer, entities - mcrfpy.createScene("dijkstra_debug") + dijkstra_debug = mcrfpy.Scene("dijkstra_debug") # Small grid for easy debugging grid = mcrfpy.Grid(grid_x=10, grid_y=10) @@ -140,7 +140,7 @@ grid = create_simple_map() test_path_highlighting() # Set up UI -ui = mcrfpy.sceneUI("dijkstra_debug") +ui = dijkstra_debug.children ui.append(grid) # Position and scale @@ -158,8 +158,8 @@ info.fill_color = mcrfpy.Color(200, 200, 200) ui.append(info) # Set up scene -mcrfpy.keypressScene(handle_keypress) -mcrfpy.setScene("dijkstra_debug") +dijkstra_debug.on_key = handle_keypress +dijkstra_debug.activate() print("\nScene ready. The path should be highlighted in cyan.") print("If you don't see the path, there may be a rendering issue.") diff --git a/tests/integration/dijkstra_interactive.py b/tests/integration/dijkstra_interactive.py index c9deeae..e91153e 100644 --- a/tests/integration/dijkstra_interactive.py +++ b/tests/integration/dijkstra_interactive.py @@ -38,7 +38,7 @@ def create_map(): """Create the interactive map with the layout specified by the user""" global grid, color_layer, entities - mcrfpy.createScene("dijkstra_interactive") + dijkstra_interactive = mcrfpy.Scene("dijkstra_interactive") # Create grid - 14x10 as specified grid = mcrfpy.Grid(grid_x=14, grid_y=10) @@ -194,7 +194,7 @@ print(" Q/ESC - Quit") grid = create_map() # Set up UI -ui = mcrfpy.sceneUI("dijkstra_interactive") +ui = dijkstra_interactive.children ui.append(grid) # Scale and position grid for better visibility @@ -235,10 +235,10 @@ for i, entity in enumerate(entities): ui.append(marker) # Set up input handling -mcrfpy.keypressScene(handle_keypress) +dijkstra_interactive.on_key = handle_keypress # Show the scene -mcrfpy.setScene("dijkstra_interactive") +dijkstra_interactive.activate() print("\nVisualization ready!") print("Entities are at:") diff --git a/tests/integration/dijkstra_interactive_enhanced.py b/tests/integration/dijkstra_interactive_enhanced.py index 35c8655..69e57fe 100644 --- a/tests/integration/dijkstra_interactive_enhanced.py +++ b/tests/integration/dijkstra_interactive_enhanced.py @@ -46,7 +46,7 @@ def create_map(): """Create the interactive map with the layout specified by the user""" global grid, color_layer, entities, original_positions - mcrfpy.createScene("dijkstra_enhanced") + dijkstra_enhanced = mcrfpy.Scene("dijkstra_enhanced") # Create grid - 14x10 as specified grid = mcrfpy.Grid(grid_x=14, grid_y=10) @@ -286,7 +286,7 @@ print(" Q/ESC - Quit") grid = create_map() # Set up UI -ui = mcrfpy.sceneUI("dijkstra_enhanced") +ui = dijkstra_enhanced.children ui.append(grid) # Scale and position grid for better visibility @@ -332,13 +332,13 @@ for i, entity in enumerate(entities): ui.append(marker) # Set up input handling -mcrfpy.keypressScene(handle_keypress) +dijkstra_enhanced.on_key = handle_keypress # Set up animation timer (60 FPS) mcrfpy.setTimer("animation", update_animation, 16) # Show the scene -mcrfpy.setScene("dijkstra_enhanced") +dijkstra_enhanced.activate() print("\nVisualization ready!") print("Entities are at:") diff --git a/tests/integration/dijkstra_test.py b/tests/integration/dijkstra_test.py index 928a56e..79da530 100644 --- a/tests/integration/dijkstra_test.py +++ b/tests/integration/dijkstra_test.py @@ -12,7 +12,7 @@ import sys def create_test_map(): """Create a test map with obstacles""" - mcrfpy.createScene("dijkstra_test") + dijkstra_test = mcrfpy.Scene("dijkstra_test") # Create grid grid = mcrfpy.Grid(grid_x=20, grid_y=12) @@ -120,7 +120,7 @@ print("Creating Dijkstra pathfinding test...") grid, entities = create_test_map() # Set up UI -ui = mcrfpy.sceneUI("dijkstra_test") +ui = dijkstra_test.children ui.append(grid) # Position and scale grid @@ -138,7 +138,7 @@ legend.fill_color = mcrfpy.Color(180, 180, 180) ui.append(legend) # Set scene -mcrfpy.setScene("dijkstra_test") +dijkstra_test.activate() # Run test after scene loads mcrfpy.setTimer("test", run_test, 100) diff --git a/tests/integration/interactive_visibility.py b/tests/integration/interactive_visibility.py index dcb386d..762b81c 100644 --- a/tests/integration/interactive_visibility.py +++ b/tests/integration/interactive_visibility.py @@ -15,7 +15,7 @@ import mcrfpy import sys # Create scene and grid -mcrfpy.createScene("visibility_demo") +visibility_demo = mcrfpy.Scene("visibility_demo") grid = mcrfpy.Grid(grid_x=30, grid_y=20) grid.fill_color = mcrfpy.Color(20, 20, 30) # Dark background @@ -77,7 +77,7 @@ current_perspective = -1 perspective_names = ["Omniscient", "Player", "Enemy"] # UI Setup -ui = mcrfpy.sceneUI("visibility_demo") +ui = visibility_demo.children ui.append(grid) grid.position = (50, 100) grid.size = (900, 600) # 30*30, 20*30 @@ -187,10 +187,10 @@ def handle_keys(key, state): update_info() # Set scene first -mcrfpy.setScene("visibility_demo") +visibility_demo.activate() # Register key handler (operates on current scene) -mcrfpy.keypressScene(handle_keys) +visibility_demo.on_key = handle_keys print("Interactive Visibility Demo") print("===========================") diff --git a/tests/integration/simple_interactive_visibility.py b/tests/integration/simple_interactive_visibility.py index 6243ecb..6ca9ac1 100644 --- a/tests/integration/simple_interactive_visibility.py +++ b/tests/integration/simple_interactive_visibility.py @@ -6,7 +6,7 @@ import sys # Create scene and grid print("Creating scene...") -mcrfpy.createScene("vis_test") +vis_test = mcrfpy.Scene("vis_test") print("Creating grid...") grid = mcrfpy.Grid(grid_x=10, grid_y=10) @@ -33,7 +33,7 @@ entity.update_visibility() # Set up UI print("Setting up UI...") -ui = mcrfpy.sceneUI("vis_test") +ui = vis_test.children ui.append(grid) grid.position = (50, 50) grid.size = (300, 300) @@ -44,6 +44,6 @@ grid.perspective = -1 # Omniscient print(f"Perspective set to: {grid.perspective}") print("Setting scene...") -mcrfpy.setScene("vis_test") +vis_test.activate() print("Ready!") \ No newline at end of file diff --git a/tests/integration/simple_visibility_test.py b/tests/integration/simple_visibility_test.py index 1e00b73..a29c081 100644 --- a/tests/integration/simple_visibility_test.py +++ b/tests/integration/simple_visibility_test.py @@ -7,7 +7,7 @@ import sys print("Simple visibility test...") # Create scene and grid -mcrfpy.createScene("simple") +simple = mcrfpy.Scene("simple") print("Scene created") grid = mcrfpy.Grid(grid_x=5, grid_y=5) diff --git a/tests/notes/test_exception_exit.py b/tests/notes/test_exception_exit.py index 348c88b..0acc236 100644 --- a/tests/notes/test_exception_exit.py +++ b/tests/notes/test_exception_exit.py @@ -14,8 +14,8 @@ def timer_that_raises(runtime): raise ValueError("Intentional test exception") # Create a test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule the timer - it will fire after 50ms mcrfpy.setTimer("raise_exception", timer_that_raises, 50) diff --git a/tests/regression/issue_123_chunk_system_test.py b/tests/regression/issue_123_chunk_system_test.py index f8be052..f26e260 100644 --- a/tests/regression/issue_123_chunk_system_test.py +++ b/tests/regression/issue_123_chunk_system_test.py @@ -181,8 +181,8 @@ if __name__ == "__main__": print("Issue #123: Grid Sub-grid Chunk System Test") print("=" * 60) - mcrfpy.createScene("test") - mcrfpy.setScene("test") + test = mcrfpy.Scene("test") + test.activate() # Run tests after scene is active mcrfpy.setTimer("test", run_test, 100) diff --git a/tests/regression/issue_146_fov_returns_none.py b/tests/regression/issue_146_fov_returns_none.py index 8cecd3b..c8b9d8f 100644 --- a/tests/regression/issue_146_fov_returns_none.py +++ b/tests/regression/issue_146_fov_returns_none.py @@ -20,8 +20,8 @@ def run_test(runtime): print("=" * 60) # Create a test grid - mcrfpy.createScene("test") - ui = mcrfpy.sceneUI("test") + test = mcrfpy.Scene("test") + ui = test.children texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) grid = mcrfpy.Grid(pos=(0,0), size=(400,300), grid_size=(50, 50), texture=texture) @@ -109,6 +109,6 @@ def run_test(runtime): sys.exit(0) # Initialize and run -mcrfpy.createScene("init") -mcrfpy.setScene("init") +init = mcrfpy.Scene("init") +init.activate() mcrfpy.setTimer("test", run_test, 100) diff --git a/tests/regression/issue_147_grid_layers.py b/tests/regression/issue_147_grid_layers.py index 3f1b8b9..0f51d26 100644 --- a/tests/regression/issue_147_grid_layers.py +++ b/tests/regression/issue_147_grid_layers.py @@ -17,8 +17,8 @@ def run_test(runtime): print("=" * 60) # Create test scene - mcrfpy.createScene("test") - ui = mcrfpy.sceneUI("test") + test = mcrfpy.Scene("test") + ui = test.children texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) # Create grid with explicit empty layers (#150 migration) @@ -188,6 +188,6 @@ def run_test(runtime): sys.exit(0) # Initialize and run -mcrfpy.createScene("init") -mcrfpy.setScene("init") +init = mcrfpy.Scene("init") +init.activate() mcrfpy.setTimer("test", run_test, 100) diff --git a/tests/regression/issue_148_layer_dirty_flags.py b/tests/regression/issue_148_layer_dirty_flags.py index cc338da..fbe53c5 100644 --- a/tests/regression/issue_148_layer_dirty_flags.py +++ b/tests/regression/issue_148_layer_dirty_flags.py @@ -20,14 +20,14 @@ def run_test(runtime): print("=" * 60) # Create test scene - mcrfpy.createScene("test") - ui = mcrfpy.sceneUI("test") + test = mcrfpy.Scene("test") + ui = test.children texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16) # Create grid with larger size for performance testing grid = mcrfpy.Grid(pos=(50, 50), size=(500, 400), grid_size=(50, 40), texture=texture) ui.append(grid) - mcrfpy.setScene("test") + test.activate() print("\n--- Test 1: Layer creation (starts dirty) ---") color_layer = grid.add_layer("color", z_index=-1) @@ -106,7 +106,7 @@ def run_test(runtime): # First render will be slow (cache miss) start = time.time() - mcrfpy.setScene("test") # Force render + test.activate() # Force render first_render = time.time() - start print(f" First render (cache build): {first_render*1000:.2f}ms") @@ -152,6 +152,6 @@ def run_test(runtime): sys.exit(0) # Initialize and run -mcrfpy.createScene("init") -mcrfpy.setScene("init") +init = mcrfpy.Scene("init") +init.activate() mcrfpy.setTimer("test", run_test, 100) diff --git a/tests/regression/issue_37_simple_test.py b/tests/regression/issue_37_simple_test.py index a6d17b5..71e68cd 100644 --- a/tests/regression/issue_37_simple_test.py +++ b/tests/regression/issue_37_simple_test.py @@ -15,7 +15,7 @@ print(f"Current working directory: {os.getcwd()}") print(f"Script location: {__file__}") # Create a simple scene to verify everything is working -mcrfpy.createScene("issue37_test") +issue37_test = mcrfpy.Scene("issue37_test") print("PASS: Issue #37 - Script loading working correctly") sys.exit(0) \ No newline at end of file diff --git a/tests/regression/issue_37_test.py b/tests/regression/issue_37_test.py index d0f882e..16f3dbe 100644 --- a/tests/regression/issue_37_test.py +++ b/tests/regression/issue_37_test.py @@ -27,7 +27,7 @@ def test_script_loading(): test_script = """ import mcrfpy print("TEST SCRIPT LOADED SUCCESSFULLY") -mcrfpy.createScene("test_scene") +test_scene = mcrfpy.Scene("test_scene") """ # Save the original game.py diff --git a/tests/regression/issue_76_test.py b/tests/regression/issue_76_test.py index ecd985d..52dbadd 100644 --- a/tests/regression/issue_76_test.py +++ b/tests/regression/issue_76_test.py @@ -81,8 +81,8 @@ def run_test(runtime): sys.exit(0) # Set up the test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 100) \ No newline at end of file diff --git a/tests/regression/issue_79_color_properties_test.py b/tests/regression/issue_79_color_properties_test.py index 05233b2..97b9c3c 100644 --- a/tests/regression/issue_79_color_properties_test.py +++ b/tests/regression/issue_79_color_properties_test.py @@ -163,8 +163,8 @@ def run_test(runtime): sys.exit(0) # Set up the test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 100) \ No newline at end of file diff --git a/tests/regression/issue_99_texture_font_properties_test.py b/tests/regression/issue_99_texture_font_properties_test.py index 1ee5277..6f5e1f3 100644 --- a/tests/regression/issue_99_texture_font_properties_test.py +++ b/tests/regression/issue_99_texture_font_properties_test.py @@ -217,8 +217,8 @@ def run_test(runtime): sys.exit(0) # Set up the test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 100) \ No newline at end of file diff --git a/tests/regression/issue_9_minimal_test.py b/tests/regression/issue_9_minimal_test.py index 09eb9c6..31e769e 100644 --- a/tests/regression/issue_9_minimal_test.py +++ b/tests/regression/issue_9_minimal_test.py @@ -21,7 +21,7 @@ def run_test(runtime): grid.h = 300 # Add to scene - scene_ui = mcrfpy.sceneUI("test") + scene_ui = test.children scene_ui.append(grid) # Test accessing grid points @@ -60,8 +60,8 @@ def run_test(runtime): sys.exit(0) # Create and set scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test mcrfpy.setTimer("test", run_test, 100) \ No newline at end of file diff --git a/tests/regression/issue_9_rendertexture_resize_test.py b/tests/regression/issue_9_rendertexture_resize_test.py index 8d643b5..b6060a0 100644 --- a/tests/regression/issue_9_rendertexture_resize_test.py +++ b/tests/regression/issue_9_rendertexture_resize_test.py @@ -45,7 +45,7 @@ def test_rendertexture_resize(): """Test RenderTexture behavior with various grid sizes""" print("=== Testing UIGrid RenderTexture Resize (Issue #9) ===\n") - scene_ui = mcrfpy.sceneUI("test") + scene_ui = test.children # Test 1: Small grid (should work fine) print("--- Test 1: Small Grid (400x300) ---") @@ -222,8 +222,8 @@ def run_test(runtime): sys.exit(0) # Set up the test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 100) \ No newline at end of file diff --git a/tests/regression/issue_9_test.py b/tests/regression/issue_9_test.py index 39a1f22..e7b2cd2 100644 --- a/tests/regression/issue_9_test.py +++ b/tests/regression/issue_9_test.py @@ -20,7 +20,7 @@ def run_test(runtime): grid.h = 200 # Add grid to scene - scene_ui = mcrfpy.sceneUI("test") + scene_ui = test.children scene_ui.append(grid) # Take initial screenshot @@ -82,8 +82,8 @@ def run_test(runtime): sys.exit(0) # Set up the test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 100) \ No newline at end of file diff --git a/tests/regression/test_type_preservation_solution.py b/tests/regression/test_type_preservation_solution.py index b2d024e..5f297c7 100644 --- a/tests/regression/test_type_preservation_solution.py +++ b/tests/regression/test_type_preservation_solution.py @@ -78,6 +78,6 @@ def run_test(runtime): sys.exit(0) # Set up scene and run -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() mcrfpy.setTimer("test", run_test, 100) \ No newline at end of file diff --git a/tests/unit/WORKING_automation_test_example.py b/tests/unit/WORKING_automation_test_example.py index 91daaef..ba23ce8 100644 --- a/tests/unit/WORKING_automation_test_example.py +++ b/tests/unit/WORKING_automation_test_example.py @@ -46,9 +46,9 @@ def run_automation_tests(): print("=== Setting Up Test Scene ===") # Create scene with visible content -mcrfpy.createScene("timer_test_scene") -mcrfpy.setScene("timer_test_scene") -ui = mcrfpy.sceneUI("timer_test_scene") +timer_test_scene = mcrfpy.Scene("timer_test_scene") +timer_test_scene.activate() +ui = timer_test_scene.children # Add a bright red frame that should be visible frame = mcrfpy.Frame(pos=(100, 100), size=(400, 300), diff --git a/tests/unit/api_createScene_test.py b/tests/unit/api_createScene_test.py index b5e336e..8cb17b1 100644 --- a/tests/unit/api_createScene_test.py +++ b/tests/unit/api_createScene_test.py @@ -9,7 +9,7 @@ def test_createScene(): for scene_name in test_scenes: try: - mcrfpy.createScene(scene_name) + _scene = mcrfpy.Scene(scene_name) print(f"✓ Created scene: {scene_name}") except Exception as e: print(f"✗ Failed to create scene {scene_name}: {e}") @@ -17,8 +17,8 @@ def test_createScene(): # Try to set scene to verify it was created try: - mcrfpy.setScene("test_scene1") - current = mcrfpy.currentScene() + test_scene1.activate() # Note: ensure scene was created + current = (mcrfpy.current_scene.name if mcrfpy.current_scene else None) if current == "test_scene1": print("✓ Scene switching works correctly") else: diff --git a/tests/unit/api_setScene_currentScene_test.py b/tests/unit/api_setScene_currentScene_test.py index 0e25d0e..299af65 100644 --- a/tests/unit/api_setScene_currentScene_test.py +++ b/tests/unit/api_setScene_currentScene_test.py @@ -7,7 +7,7 @@ print("Starting setScene/currentScene test...") # Create test scenes first scenes = ["scene_A", "scene_B", "scene_C"] for scene in scenes: - mcrfpy.createScene(scene) + _scene = mcrfpy.Scene(scene) print(f"Created scene: {scene}") results = [] @@ -15,8 +15,8 @@ results = [] # Test switching between scenes for scene in scenes: try: - mcrfpy.setScene(scene) - current = mcrfpy.currentScene() + mcrfpy.current_scene = scene + current = (mcrfpy.current_scene.name if mcrfpy.current_scene else None) if current == scene: results.append(f"✓ setScene/currentScene works for '{scene}'") else: @@ -25,9 +25,9 @@ for scene in scenes: results.append(f"✗ Error with scene '{scene}': {e}") # Test invalid scene - it should not change the current scene -current_before = mcrfpy.currentScene() -mcrfpy.setScene("nonexistent_scene") -current_after = mcrfpy.currentScene() +current_before = (mcrfpy.current_scene.name if mcrfpy.current_scene else None) +nonexistent_scene.activate() # Note: ensure scene was created +current_after = (mcrfpy.current_scene.name if mcrfpy.current_scene else None) if current_before == current_after: results.append(f"✓ setScene correctly ignores nonexistent scene (stayed on '{current_after}')") else: diff --git a/tests/unit/automation_screenshot_test_simple.py b/tests/unit/automation_screenshot_test_simple.py index 75dbf77..de16a8d 100644 --- a/tests/unit/automation_screenshot_test_simple.py +++ b/tests/unit/automation_screenshot_test_simple.py @@ -6,8 +6,8 @@ import os import sys # Create a simple scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Take a screenshot immediately try: diff --git a/tests/unit/benchmark_logging_test.py b/tests/unit/benchmark_logging_test.py index 387770c..2600b05 100644 --- a/tests/unit/benchmark_logging_test.py +++ b/tests/unit/benchmark_logging_test.py @@ -128,8 +128,8 @@ mcrfpy.log_benchmark("Test log message") print("Logged test message") # Set up scene and run for a few frames -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test completion after ~100ms (to capture some frames) mcrfpy.setTimer("test", run_test, 100) diff --git a/tests/unit/collection_find_test.py b/tests/unit/collection_find_test.py index 86a1733..e7ae26f 100644 --- a/tests/unit/collection_find_test.py +++ b/tests/unit/collection_find_test.py @@ -12,8 +12,8 @@ def test_uicollection_find(): print("Testing UICollection.find()...") # Create a scene with named elements - mcrfpy.createScene("test_find") - ui = mcrfpy.sceneUI("test_find") + test_find = mcrfpy.Scene("test_find") + ui = test_find.children # Create frames with names frame1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) @@ -94,8 +94,8 @@ def test_entitycollection_find(): print("\nTesting EntityCollection.find()...") # Create a grid with entities - mcrfpy.createScene("test_entity_find") - ui = mcrfpy.sceneUI("test_entity_find") + test_entity_find = mcrfpy.Scene("test_entity_find") + ui = test_entity_find.children grid = mcrfpy.Grid(grid_size=(10, 10), pos=(0, 0), size=(400, 400)) ui.append(grid) @@ -149,8 +149,8 @@ def test_recursive_find(): """Test recursive find in nested Frame children.""" print("\nTesting recursive find in nested frames...") - mcrfpy.createScene("test_recursive") - ui = mcrfpy.sceneUI("test_recursive") + test_recursive = mcrfpy.Scene("test_recursive") + ui = test_recursive.children # Create nested structure parent = mcrfpy.Frame(pos=(0, 0), size=(400, 400)) diff --git a/tests/unit/collection_list_methods_test.py b/tests/unit/collection_list_methods_test.py index 7035099..30beae8 100644 --- a/tests/unit/collection_list_methods_test.py +++ b/tests/unit/collection_list_methods_test.py @@ -12,8 +12,8 @@ def test_uicollection_remove(): """Test UICollection.remove() takes a value, not an index.""" print("Testing UICollection.remove()...") - mcrfpy.createScene("test_remove") - ui = mcrfpy.sceneUI("test_remove") + test_remove = mcrfpy.Scene("test_remove") + ui = test_remove.children frame1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) frame2 = mcrfpy.Frame(pos=(100, 0), size=(100, 100)) @@ -58,8 +58,8 @@ def test_uicollection_pop(): """Test UICollection.pop() removes and returns element at index.""" print("\nTesting UICollection.pop()...") - mcrfpy.createScene("test_pop") - ui = mcrfpy.sceneUI("test_pop") + test_pop = mcrfpy.Scene("test_pop") + ui = test_pop.children frame1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) frame1.name = "first" @@ -108,8 +108,8 @@ def test_uicollection_insert(): """Test UICollection.insert() inserts at given index.""" print("\nTesting UICollection.insert()...") - mcrfpy.createScene("test_insert") - ui = mcrfpy.sceneUI("test_insert") + test_insert = mcrfpy.Scene("test_insert") + ui = test_insert.children frame1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) frame1.name = "first" @@ -160,8 +160,8 @@ def test_entitycollection_pop_insert(): """Test EntityCollection.pop() and insert().""" print("\nTesting EntityCollection.pop() and insert()...") - mcrfpy.createScene("test_entity_pop") - ui = mcrfpy.sceneUI("test_entity_pop") + test_entity_pop = mcrfpy.Scene("test_entity_pop") + ui = test_entity_pop.children grid = mcrfpy.Grid(grid_size=(10, 10), pos=(0, 0), size=(400, 400)) ui.append(grid) @@ -204,8 +204,8 @@ def test_index_and_count(): """Test index() and count() methods.""" print("\nTesting index() and count()...") - mcrfpy.createScene("test_index_count") - ui = mcrfpy.sceneUI("test_index_count") + test_index_count = mcrfpy.Scene("test_index_count") + ui = test_index_count.children frame1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) frame2 = mcrfpy.Frame(pos=(100, 0), size=(100, 100)) diff --git a/tests/unit/debug_empty_paths.py b/tests/unit/debug_empty_paths.py index 1485177..6aea589 100644 --- a/tests/unit/debug_empty_paths.py +++ b/tests/unit/debug_empty_paths.py @@ -7,7 +7,7 @@ import sys print("Debugging empty paths...") # Create scene and grid -mcrfpy.createScene("debug") +debug = mcrfpy.Scene("debug") grid = mcrfpy.Grid(grid_x=10, grid_y=10) # Initialize grid - all walkable @@ -72,9 +72,9 @@ def timer_cb(dt): sys.exit(0) # Quick UI setup -ui = mcrfpy.sceneUI("debug") +ui = debug.children ui.append(grid) -mcrfpy.setScene("debug") +debug.activate() mcrfpy.setTimer("exit", timer_cb, 100) print("\nStarting timer...") \ No newline at end of file diff --git a/tests/unit/debug_render_test.py b/tests/unit/debug_render_test.py index 1442f09..0c17791 100644 --- a/tests/unit/debug_render_test.py +++ b/tests/unit/debug_render_test.py @@ -11,13 +11,13 @@ print(f"Automation available: {'automation' in dir(mcrfpy)}") # Try to understand the scene state print("\nCreating and checking scene...") -mcrfpy.createScene("debug_scene") -mcrfpy.setScene("debug_scene") -current = mcrfpy.currentScene() +debug_scene = mcrfpy.Scene("debug_scene") +debug_scene.activate() +current = (mcrfpy.current_scene.name if mcrfpy.current_scene else None) print(f"Current scene: {current}") # Get UI collection -ui = mcrfpy.sceneUI("debug_scene") +ui = debug_scene.children print(f"UI collection type: {type(ui)}") print(f"Initial UI elements: {len(ui)}") diff --git a/tests/unit/generate_docs_screenshots.py b/tests/unit/generate_docs_screenshots.py index 53393fd..cd5b085 100755 --- a/tests/unit/generate_docs_screenshots.py +++ b/tests/unit/generate_docs_screenshots.py @@ -32,8 +32,8 @@ def create_caption(x, y, text, font_size=16, text_color=WHITE, outline_color=BLA def create_caption_example(): """Create a scene showing Caption UI element examples""" - mcrfpy.createScene("caption_example") - ui = mcrfpy.sceneUI("caption_example") + caption_example = mcrfpy.Scene("caption_example") + ui = caption_example.children # Background frame bg = mcrfpy.Frame(0, 0, 800, 600, fill_color=FRAME_COLOR) @@ -61,8 +61,8 @@ def create_caption_example(): def create_sprite_example(): """Create a scene showing Sprite UI element examples""" - mcrfpy.createScene("sprite_example") - ui = mcrfpy.sceneUI("sprite_example") + sprite_example = mcrfpy.Scene("sprite_example") + ui = sprite_example.children # Background frame bg = mcrfpy.Frame(0, 0, 800, 600, fill_color=FRAME_COLOR) @@ -122,8 +122,8 @@ def create_sprite_example(): def create_frame_example(): """Create a scene showing Frame UI element examples""" - mcrfpy.createScene("frame_example") - ui = mcrfpy.sceneUI("frame_example") + frame_example = mcrfpy.Scene("frame_example") + ui = frame_example.children # Background bg = mcrfpy.Frame(0, 0, 800, 600, fill_color=SHADOW_COLOR) @@ -184,8 +184,8 @@ def create_frame_example(): def create_grid_example(): """Create a scene showing Grid UI element examples""" - mcrfpy.createScene("grid_example") - ui = mcrfpy.sceneUI("grid_example") + grid_example = mcrfpy.Scene("grid_example") + ui = grid_example.children # Background bg = mcrfpy.Frame(0, 0, 800, 600, fill_color=FRAME_COLOR) @@ -234,8 +234,8 @@ def create_grid_example(): def create_entity_example(): """Create a scene showing Entity examples in a Grid""" - mcrfpy.createScene("entity_example") - ui = mcrfpy.sceneUI("entity_example") + entity_example = mcrfpy.Scene("entity_example") + ui = entity_example.children # Background bg = mcrfpy.Frame(0, 0, 800, 600, fill_color=FRAME_COLOR) @@ -310,8 +310,8 @@ def create_entity_example(): def create_combined_example(): """Create a scene showing all UI elements combined""" - mcrfpy.createScene("combined_example") - ui = mcrfpy.sceneUI("combined_example") + combined_example = mcrfpy.Scene("combined_example") + ui = combined_example.children # Background bg = mcrfpy.Frame(0, 0, 800, 600, fill_color=SHADOW_COLOR) @@ -417,7 +417,7 @@ def take_screenshots(runtime): scene_name, filename = screenshots[current_screenshot] # Switch to the scene - mcrfpy.setScene(scene_name) + mcrfpy.current_scene = scene_name # Take screenshot after a short delay to ensure rendering def capture(): @@ -435,7 +435,7 @@ def take_screenshots(runtime): mcrfpy.setTimer("capture", lambda r: capture(), 100) # Start with the first scene -mcrfpy.setScene("caption_example") +caption_example.activate() # Start the screenshot process print(f"\nStarting screenshot capture of {len(screenshots)} scenes...") diff --git a/tests/unit/generate_grid_screenshot.py b/tests/unit/generate_grid_screenshot.py index 8c4500d..51754e7 100644 --- a/tests/unit/generate_grid_screenshot.py +++ b/tests/unit/generate_grid_screenshot.py @@ -16,7 +16,7 @@ def capture_grid(runtime): sys.exit(0) # Create scene -mcrfpy.createScene("grid") +grid = mcrfpy.Scene("grid") # Load texture texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16) @@ -92,7 +92,7 @@ for i, label in enumerate(labels): l.font = mcrfpy.default_font l.font_size = 10 l.fill_color = mcrfpy.Color(255, 255, 255) - mcrfpy.sceneUI("grid").append(l) + grid.children.append(l) # Add info caption info = mcrfpy.Caption(pos=(100, 680), text="Grid supports tiles and entities. Entities can move independently of the tile grid.") @@ -101,7 +101,7 @@ info.font_size = 14 info.fill_color = mcrfpy.Color(200, 200, 200) # Add all elements to scene -ui = mcrfpy.sceneUI("grid") +ui = grid.children ui.append(title) ui.append(grid) ui.append(palette_label) @@ -109,7 +109,7 @@ ui.append(palette) ui.append(info) # Switch to scene -mcrfpy.setScene("grid") +grid.activate() # Set timer to capture after rendering starts mcrfpy.setTimer("capture", capture_grid, 100) \ No newline at end of file diff --git a/tests/unit/generate_sprite_screenshot.py b/tests/unit/generate_sprite_screenshot.py index ff6114c..d45197c 100644 --- a/tests/unit/generate_sprite_screenshot.py +++ b/tests/unit/generate_sprite_screenshot.py @@ -16,7 +16,7 @@ def capture_sprites(runtime): sys.exit(0) # Create scene -mcrfpy.createScene("sprites") +sprites = mcrfpy.Scene("sprites") # Load texture texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16) @@ -129,10 +129,10 @@ for i, scale in enumerate([1.0, 2.0, 3.0, 4.0]): s.texture = texture s.sprite_index = 84 # Player s.scale = (scale, scale) - mcrfpy.sceneUI("sprites").append(s) + sprites.children.append(s) # Add all elements to scene -ui = mcrfpy.sceneUI("sprites") +ui = sprites.children ui.append(frame) ui.append(title) ui.append(player_label) @@ -154,7 +154,7 @@ ui.append(armor) ui.append(scale_label) # Switch to scene -mcrfpy.setScene("sprites") +sprites.activate() # Set timer to capture after rendering starts mcrfpy.setTimer("capture", capture_sprites, 100) \ No newline at end of file diff --git a/tests/unit/keypress_scene_validation_test.py b/tests/unit/keypress_scene_validation_test.py index 4bd2982..de1b8f4 100644 --- a/tests/unit/keypress_scene_validation_test.py +++ b/tests/unit/keypress_scene_validation_test.py @@ -11,15 +11,15 @@ def test_keypress_validation(timer_name): print("Testing keypressScene() validation...") # Create test scene - mcrfpy.createScene("test") - mcrfpy.setScene("test") + test = mcrfpy.Scene("test") + test.activate() # Test 1: Valid callable (function) def key_handler(key, action): print(f"Key pressed: {key}, action: {action}") try: - mcrfpy.keypressScene(key_handler) + test.on_key = key_handler print("✓ Accepted valid function as key handler") except Exception as e: print(f"✗ Rejected valid function: {e}") @@ -27,7 +27,7 @@ def test_keypress_validation(timer_name): # Test 2: Valid callable (lambda) try: - mcrfpy.keypressScene(lambda k, a: None) + test.on_key = lambda k, a: None print("✓ Accepted valid lambda as key handler") except Exception as e: print(f"✗ Rejected valid lambda: {e}") @@ -35,7 +35,7 @@ def test_keypress_validation(timer_name): # Test 3: Invalid - string try: - mcrfpy.keypressScene("not callable") + test.on_key = "not callable" print("✗ Should have rejected string as key handler") except TypeError as e: print(f"✓ Correctly rejected string: {e}") @@ -45,7 +45,7 @@ def test_keypress_validation(timer_name): # Test 4: Invalid - number try: - mcrfpy.keypressScene(42) + test.on_key = 42 print("✗ Should have rejected number as key handler") except TypeError as e: print(f"✓ Correctly rejected number: {e}") @@ -55,7 +55,7 @@ def test_keypress_validation(timer_name): # Test 5: Invalid - None try: - mcrfpy.keypressScene(None) + test.on_key = None print("✗ Should have rejected None as key handler") except TypeError as e: print(f"✓ Correctly rejected None: {e}") @@ -65,7 +65,7 @@ def test_keypress_validation(timer_name): # Test 6: Invalid - dict try: - mcrfpy.keypressScene({"not": "callable"}) + test.on_key = {"not": "callable"} print("✗ Should have rejected dict as key handler") except TypeError as e: print(f"✓ Correctly rejected dict: {e}") @@ -79,7 +79,7 @@ def test_keypress_validation(timer_name): print(f"Class handler: {key}, {action}") try: - mcrfpy.keypressScene(KeyHandler()) + test.on_key = KeyHandler() print("✓ Accepted valid callable class instance") except Exception as e: print(f"✗ Rejected valid callable class: {e}") diff --git a/tests/unit/screenshot_transparency_fix_test.py b/tests/unit/screenshot_transparency_fix_test.py index 5d5e333..7f9e92d 100644 --- a/tests/unit/screenshot_transparency_fix_test.py +++ b/tests/unit/screenshot_transparency_fix_test.py @@ -10,9 +10,9 @@ def test_transparency_workaround(): print("=== Screenshot Transparency Fix Test ===\n") # Create a scene - mcrfpy.createScene("opaque_test") - mcrfpy.setScene("opaque_test") - ui = mcrfpy.sceneUI("opaque_test") + opaque_test = mcrfpy.Scene("opaque_test") + opaque_test.activate() + ui = opaque_test.children # WORKAROUND: Create a full-window opaque frame as the first element # This acts as an opaque background since the scene clears with transparent diff --git a/tests/unit/simple_screenshot_test.py b/tests/unit/simple_screenshot_test.py index 3117a81..a23aeae 100644 --- a/tests/unit/simple_screenshot_test.py +++ b/tests/unit/simple_screenshot_test.py @@ -28,7 +28,7 @@ def take_screenshot(runtime): sys.exit(0) # Create minimal scene -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") # Add a visible element caption = mcrfpy.Caption(pos=(100, 100), text="Screenshot Test") @@ -36,8 +36,8 @@ caption.font = mcrfpy.default_font caption.fill_color = mcrfpy.Color(255, 255, 255) caption.font_size = 24 -mcrfpy.sceneUI("test").append(caption) -mcrfpy.setScene("test") +test.children.append(caption) +test.activate() # Use timer to ensure rendering has started print("Setting timer...") diff --git a/tests/unit/simple_timer_screenshot_test.py b/tests/unit/simple_timer_screenshot_test.py index d4aa001..cfa61fc 100644 --- a/tests/unit/simple_timer_screenshot_test.py +++ b/tests/unit/simple_timer_screenshot_test.py @@ -25,9 +25,9 @@ def take_screenshot_and_exit(): # Set up a simple scene print("Creating test scene...") -mcrfpy.createScene("test") -mcrfpy.setScene("test") -ui = mcrfpy.sceneUI("test") +test = mcrfpy.Scene("test") +test.activate() +ui = test.children # Add visible content - a white frame on default background frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200), diff --git a/tests/unit/test_animation_callback_simple.py b/tests/unit/test_animation_callback_simple.py index f3c0819..9a759c6 100644 --- a/tests/unit/test_animation_callback_simple.py +++ b/tests/unit/test_animation_callback_simple.py @@ -17,12 +17,12 @@ def my_callback(anim, target): def setup_and_run(): """Set up scene and run animation with callback""" # Create scene - mcrfpy.createScene("callback_demo") - mcrfpy.setScene("callback_demo") + callback_demo = mcrfpy.Scene("callback_demo") + callback_demo.activate() # Create a frame to animate frame = mcrfpy.Frame((100, 100), (200, 200), fill_color=(255, 0, 0)) - ui = mcrfpy.sceneUI("callback_demo") + ui = callback_demo.children ui.append(frame) # Create animation with callback @@ -42,7 +42,7 @@ def check_result(runtime): # Test 2: Animation without callback print("\nTesting animation without callback...") - ui = mcrfpy.sceneUI("callback_demo") + ui = callback_demo.children frame = ui[0] anim2 = mcrfpy.Animation("y", 300.0, 0.5, "linear") diff --git a/tests/unit/test_animation_chaining.py b/tests/unit/test_animation_chaining.py index 7b3700a..2e069dd 100644 --- a/tests/unit/test_animation_chaining.py +++ b/tests/unit/test_animation_chaining.py @@ -67,7 +67,7 @@ class PathAnimator: self._animate_next_step() # Create test scene -mcrfpy.createScene("chain_test") +chain_test = mcrfpy.Scene("chain_test") # Create grid grid = mcrfpy.Grid(grid_x=20, grid_y=15) @@ -97,7 +97,7 @@ enemy = mcrfpy.Entity((17, 12), grid=grid) enemy.sprite_index = 69 # E # UI setup -ui = mcrfpy.sceneUI("chain_test") +ui = chain_test.children ui.append(grid) grid.position = (100, 100) grid.size = (600, 450) @@ -201,8 +201,8 @@ def handle_input(key, state): info.text = "Positions reset" # Setup -mcrfpy.setScene("chain_test") -mcrfpy.keypressScene(handle_input) +chain_test.activate() +chain_test.on_key = handle_input # Camera update timer mcrfpy.setTimer("cam_update", update_camera, 100) diff --git a/tests/unit/test_animation_debug.py b/tests/unit/test_animation_debug.py index 16c21a7..9f1c4ce 100644 --- a/tests/unit/test_animation_debug.py +++ b/tests/unit/test_animation_debug.py @@ -59,7 +59,7 @@ class AnimationTracker: mcrfpy.delTimer(f"check_{self.name}") # Create test scene -mcrfpy.createScene("anim_debug") +anim_debug = mcrfpy.Scene("anim_debug") # Simple grid grid = mcrfpy.Grid(grid_x=15, grid_y=10) @@ -75,7 +75,7 @@ entity = mcrfpy.Entity((5, 5), grid=grid) entity.sprite_index = 64 # UI -ui = mcrfpy.sceneUI("anim_debug") +ui = anim_debug.children ui.append(grid) grid.position = (100, 150) grid.size = (450, 300) @@ -215,8 +215,8 @@ def handle_input(key, state): print("Reset entity and cleared log") # Setup -mcrfpy.setScene("anim_debug") -mcrfpy.keypressScene(handle_input) +anim_debug.activate() +anim_debug.on_key = handle_input mcrfpy.setTimer("update", update_display, 100) print("Animation Debug Tool") diff --git a/tests/unit/test_animation_immediate.py b/tests/unit/test_animation_immediate.py index e78c63c..d9127d1 100644 --- a/tests/unit/test_animation_immediate.py +++ b/tests/unit/test_animation_immediate.py @@ -6,11 +6,11 @@ Test Animation creation without timer import mcrfpy print("1. Creating scene...") -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() print("2. Getting UI...") -ui = mcrfpy.sceneUI("test") +ui = test.children print("3. Creating frame...") frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) diff --git a/tests/unit/test_animation_property_locking.py b/tests/unit/test_animation_property_locking.py index 3b25892..694206e 100644 --- a/tests/unit/test_animation_property_locking.py +++ b/tests/unit/test_animation_property_locking.py @@ -30,7 +30,7 @@ def test_result(name, passed, details=""): def test_1_replace_mode_default(): """Test that REPLACE mode is the default and works correctly""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -55,7 +55,7 @@ def test_1_replace_mode_default(): def test_2_replace_mode_explicit(): """Test explicit REPLACE mode""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -73,7 +73,7 @@ def test_2_replace_mode_explicit(): def test_3_queue_mode(): """Test QUEUE mode - animation should be queued""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -95,7 +95,7 @@ def test_3_queue_mode(): def test_4_error_mode(): """Test ERROR mode - should raise RuntimeError""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -120,7 +120,7 @@ def test_4_error_mode(): def test_5_invalid_conflict_mode(): """Test that invalid conflict_mode raises ValueError""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -140,7 +140,7 @@ def test_5_invalid_conflict_mode(): def test_6_different_properties_no_conflict(): """Test that different properties can animate simultaneously""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -164,7 +164,7 @@ def test_6_different_properties_no_conflict(): def test_7_different_targets_no_conflict(): """Test that same property on different targets doesn't conflict""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame1 = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) frame2 = mcrfpy.Frame(pos=(200, 200), size=(100, 100)) ui.append(frame1) @@ -187,7 +187,7 @@ def test_7_different_targets_no_conflict(): def test_8_replace_completes_old(): """Test that REPLACE mode completes the old animation's value""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) ui.append(frame) @@ -242,8 +242,8 @@ def run_all_tests(runtime): # Setup and run -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Start tests after a brief delay to allow scene to initialize mcrfpy.setTimer("start", run_all_tests, 100) diff --git a/tests/unit/test_animation_raii.py b/tests/unit/test_animation_raii.py index 53de59b..b7e556b 100644 --- a/tests/unit/test_animation_raii.py +++ b/tests/unit/test_animation_raii.py @@ -29,7 +29,7 @@ def test_result(name, passed, details=""): def test_1_basic_animation(): """Test that basic animations still work""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -48,7 +48,7 @@ def test_1_basic_animation(): def test_2_remove_animated_object(): """Test removing object with active animation""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -72,7 +72,7 @@ def test_2_remove_animated_object(): def test_3_complete_animation(): """Test completing animation immediately""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) ui.append(frame) @@ -97,7 +97,7 @@ def test_4_multiple_animations_timer(): def create_animations(runtime): nonlocal success try: - ui = mcrfpy.sceneUI("test") + ui = test.children frame = mcrfpy.Frame(pos=(200, 200), size=(100, 100)) ui.append(frame) @@ -113,7 +113,7 @@ def test_4_multiple_animations_timer(): mcrfpy.setTimer("exit", lambda t: None, 100) # Clear scene - ui = mcrfpy.sceneUI("test") + ui = test.children while len(ui) > 0: ui.remove(len(ui) - 1) @@ -124,10 +124,10 @@ def test_5_scene_cleanup(): """Test that changing scenes cleans up animations""" try: # Create a second scene - mcrfpy.createScene("test2") + test2 = mcrfpy.Scene("test2") # Add animated objects to first scene - ui = mcrfpy.sceneUI("test") + ui = test.children for i in range(5): frame = mcrfpy.Frame(pos=(50 * i, 100), size=(40, 40)) ui.append(frame) @@ -135,10 +135,10 @@ def test_5_scene_cleanup(): anim.start(frame) # Switch scenes (animations should become invalid) - mcrfpy.setScene("test2") + test2.activate() # Switch back - mcrfpy.setScene("test") + test.activate() test_result("Scene change cleanup", True) except Exception as e: @@ -147,7 +147,7 @@ def test_5_scene_cleanup(): def test_6_animation_after_clear(): """Test animations after clearing UI""" try: - ui = mcrfpy.sceneUI("test") + ui = test.children # Create and animate frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) @@ -202,11 +202,11 @@ def print_results(runtime): mcrfpy.setTimer("exit", lambda t: sys.exit(0 if tests_failed == 0 else 1), 500) # Setup and run -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Add a background -ui = mcrfpy.sceneUI("test") +ui = test.children bg = mcrfpy.Frame(pos=(0, 0), size=(1024, 768)) bg.fill_color = mcrfpy.Color(20, 20, 30) ui.append(bg) diff --git a/tests/unit/test_animation_removal.py b/tests/unit/test_animation_removal.py index 3aac09d..ec0191f 100644 --- a/tests/unit/test_animation_removal.py +++ b/tests/unit/test_animation_removal.py @@ -10,7 +10,7 @@ def clear_and_recreate(runtime): """Clear UI and recreate - mimics demo switching""" print(f"\nTimer called at {runtime}") - ui = mcrfpy.sceneUI("test") + ui = test.children # Remove all but first 2 items (like clear_demo_objects) print(f"Scene has {len(ui)} elements before clearing") @@ -37,9 +37,9 @@ def clear_and_recreate(runtime): # Create initial scene print("Creating scene...") -mcrfpy.createScene("test") -mcrfpy.setScene("test") -ui = mcrfpy.sceneUI("test") +test = mcrfpy.Scene("test") +test.activate() +ui = test.children # Add title and subtitle (to preserve during clearing) title = mcrfpy.Caption(pos=(400, 20), text="Test Title") diff --git a/tests/unit/test_astar.py b/tests/unit/test_astar.py index f0afadb..db49633 100644 --- a/tests/unit/test_astar.py +++ b/tests/unit/test_astar.py @@ -14,7 +14,7 @@ print("A* Pathfinding Test") print("==================") # Create scene and grid -mcrfpy.createScene("astar_test") +astar_test = mcrfpy.Scene("astar_test") grid = mcrfpy.Grid(grid_x=20, grid_y=20) # Initialize grid - all walkable @@ -119,12 +119,12 @@ def visual_test(runtime): sys.exit(0) # Set up minimal UI for visual test -ui = mcrfpy.sceneUI("astar_test") +ui = astar_test.children ui.append(grid) grid.position = (50, 50) grid.size = (400, 400) -mcrfpy.setScene("astar_test") +astar_test.activate() mcrfpy.setTimer("visual", visual_test, 100) print("\nStarting visual test...") \ No newline at end of file diff --git a/tests/unit/test_audio_cleanup.py b/tests/unit/test_audio_cleanup.py index a2ca61f..db49bae 100644 --- a/tests/unit/test_audio_cleanup.py +++ b/tests/unit/test_audio_cleanup.py @@ -6,6 +6,6 @@ import sys print("Testing audio cleanup...") # Create a scene and immediately exit -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") print("Exiting now...") sys.exit(0) \ No newline at end of file diff --git a/tests/unit/test_bounds_hit_testing.py b/tests/unit/test_bounds_hit_testing.py index 93edd61..a4ce7e7 100644 --- a/tests/unit/test_bounds_hit_testing.py +++ b/tests/unit/test_bounds_hit_testing.py @@ -8,8 +8,8 @@ def test_bounds_property(): """Test bounds property returns correct local bounds""" print("Testing bounds property...") - mcrfpy.createScene("test_bounds") - ui = mcrfpy.sceneUI("test_bounds") + test_bounds = mcrfpy.Scene("test_bounds") + ui = test_bounds.children frame = mcrfpy.Frame(pos=(50, 75), size=(200, 150)) ui.append(frame) @@ -27,8 +27,8 @@ def test_global_bounds_no_parent(): """Test global_bounds equals bounds when no parent""" print("Testing global_bounds without parent...") - mcrfpy.createScene("test_gb1") - ui = mcrfpy.sceneUI("test_gb1") + test_gb1 = mcrfpy.Scene("test_gb1") + ui = test_gb1.children frame = mcrfpy.Frame(pos=(100, 100), size=(50, 50)) ui.append(frame) @@ -45,8 +45,8 @@ def test_global_bounds_with_parent(): """Test global_bounds correctly adds parent offset""" print("Testing global_bounds with parent...") - mcrfpy.createScene("test_gb2") - ui = mcrfpy.sceneUI("test_gb2") + test_gb2 = mcrfpy.Scene("test_gb2") + ui = test_gb2.children parent = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) ui.append(parent) @@ -67,8 +67,8 @@ def test_global_bounds_nested(): """Test global_bounds with deeply nested hierarchy""" print("Testing global_bounds with nested hierarchy...") - mcrfpy.createScene("test_gb3") - ui = mcrfpy.sceneUI("test_gb3") + test_gb3 = mcrfpy.Scene("test_gb3") + ui = test_gb3.children # Create 3-level hierarchy root = mcrfpy.Frame(pos=(10, 10), size=(300, 300)) @@ -92,8 +92,8 @@ def test_all_drawable_types_have_bounds(): """Test that all drawable types have bounds properties""" print("Testing bounds on all drawable types...") - mcrfpy.createScene("test_types") - ui = mcrfpy.sceneUI("test_types") + test_types = mcrfpy.Scene("test_types") + ui = test_types.children types_to_test = [ ("Frame", mcrfpy.Frame(pos=(0, 0), size=(100, 100))), diff --git a/tests/unit/test_builtin_context.py b/tests/unit/test_builtin_context.py index 271f8e6..bac8882 100644 --- a/tests/unit/test_builtin_context.py +++ b/tests/unit/test_builtin_context.py @@ -37,7 +37,7 @@ print() print("Test 3: Function creating mcrfpy objects") def create_scene(): try: - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") print(" ✓ Created scene") # Now try range @@ -69,7 +69,7 @@ print() print("Test 4: Exact failing pattern") def failing_pattern(): try: - mcrfpy.createScene("failing_test") + failing_test = mcrfpy.Scene("failing_test") grid = mcrfpy.Grid(grid_x=14, grid_y=10) # This is where it fails in the demos diff --git a/tests/unit/test_color_fix.py b/tests/unit/test_color_fix.py index d9fa7dc..9728544 100644 --- a/tests/unit/test_color_fix.py +++ b/tests/unit/test_color_fix.py @@ -7,7 +7,7 @@ print("Testing Color fix...") # Test 1: Create grid try: - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") grid = mcrfpy.Grid(grid_x=5, grid_y=5) print("✓ Grid created") except Exception as e: diff --git a/tests/unit/test_color_helpers.py b/tests/unit/test_color_helpers.py index 49e8b65..95e4aa3 100644 --- a/tests/unit/test_color_helpers.py +++ b/tests/unit/test_color_helpers.py @@ -178,5 +178,5 @@ def test_color_helpers(runtime): sys.exit(0 if all_pass else 1) # Run test -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") mcrfpy.setTimer("test", test_color_helpers, 100) \ No newline at end of file diff --git a/tests/unit/test_color_operations.py b/tests/unit/test_color_operations.py index 61c278d..8ce5cf0 100644 --- a/tests/unit/test_color_operations.py +++ b/tests/unit/test_color_operations.py @@ -9,7 +9,7 @@ print("=" * 50) # Test 1: Basic Color assignment print("Test 1: Color assignment in grid") try: - mcrfpy.createScene("test1") + test1 = mcrfpy.Scene("test1") grid = mcrfpy.Grid(grid_x=25, grid_y=15) # Assign color to a cell @@ -27,7 +27,7 @@ except Exception as e: # Test 2: Multiple color assignments print("\nTest 2: Multiple color assignments") try: - mcrfpy.createScene("test2") + test2 = mcrfpy.Scene("test2") grid = mcrfpy.Grid(grid_x=25, grid_y=15) # Multiple properties including color @@ -54,7 +54,7 @@ print("\nTest 3: Exact pattern from dijkstra_demo_final.py") try: # Recreate the exact function def create_demo(): - mcrfpy.createScene("dijkstra_demo") + dijkstra_demo = mcrfpy.Scene("dijkstra_demo") # Create grid grid = mcrfpy.Grid(grid_x=25, grid_y=15) diff --git a/tests/unit/test_color_setter_bug.py b/tests/unit/test_color_setter_bug.py index 97b5b7d..082e626 100644 --- a/tests/unit/test_color_setter_bug.py +++ b/tests/unit/test_color_setter_bug.py @@ -9,7 +9,7 @@ print("=" * 50) # Test 1: Setting color with tuple (old way) print("Test 1: Setting color with tuple") try: - mcrfpy.createScene("test1") + test1 = mcrfpy.Scene("test1") grid = mcrfpy.Grid(grid_x=5, grid_y=5) # This should work (PyArg_ParseTuple expects tuple) @@ -26,7 +26,7 @@ print() # Test 2: Setting color with Color object (the bug) print("Test 2: Setting color with Color object") try: - mcrfpy.createScene("test2") + test2 = mcrfpy.Scene("test2") grid = mcrfpy.Grid(grid_x=5, grid_y=5) # This will fail in PyArg_ParseTuple but not report it @@ -45,7 +45,7 @@ print() # Test 3: Multiple color assignments print("Test 3: Multiple Color assignments (reproducing original bug)") try: - mcrfpy.createScene("test3") + test3 = mcrfpy.Scene("test3") grid = mcrfpy.Grid(grid_x=25, grid_y=15) # Do multiple color assignments diff --git a/tests/unit/test_dijkstra_pathfinding.py b/tests/unit/test_dijkstra_pathfinding.py index a28b103..7276e13 100644 --- a/tests/unit/test_dijkstra_pathfinding.py +++ b/tests/unit/test_dijkstra_pathfinding.py @@ -16,7 +16,7 @@ import sys def create_test_grid(): """Create a test grid with obstacles""" - mcrfpy.createScene("dijkstra_test") + dijkstra_test = mcrfpy.Scene("dijkstra_test") # Create grid grid = mcrfpy.Grid(grid_x=20, grid_y=20) @@ -212,7 +212,7 @@ print("=====================================") # Set up scene grid = create_test_grid() -ui = mcrfpy.sceneUI("dijkstra_test") +ui = dijkstra_test.children ui.append(grid) # Add title @@ -224,4 +224,4 @@ ui.append(title) mcrfpy.setTimer("test", run_test, 100) # Show scene -mcrfpy.setScene("dijkstra_test") \ No newline at end of file +dijkstra_test.activate() \ No newline at end of file diff --git a/tests/unit/test_empty_animation_manager.py b/tests/unit/test_empty_animation_manager.py index c86905a..52955ae 100644 --- a/tests/unit/test_empty_animation_manager.py +++ b/tests/unit/test_empty_animation_manager.py @@ -6,8 +6,8 @@ Test if AnimationManager crashes with no animations import mcrfpy print("Creating empty scene...") -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() print("Scene created, no animations added") print("Starting game loop in 100ms...") diff --git a/tests/unit/test_entity_animation.py b/tests/unit/test_entity_animation.py index 2cf539e..d28a89a 100644 --- a/tests/unit/test_entity_animation.py +++ b/tests/unit/test_entity_animation.py @@ -11,7 +11,7 @@ import mcrfpy import sys # Create scene -mcrfpy.createScene("test_anim") +test_anim = mcrfpy.Scene("test_anim") # Create simple grid grid = mcrfpy.Grid(grid_x=15, grid_y=15) @@ -42,7 +42,7 @@ entity = mcrfpy.Entity((5, 5), grid=grid) entity.sprite_index = 64 # @ # UI setup -ui = mcrfpy.sceneUI("test_anim") +ui = test_anim.children ui.append(grid) grid.position = (100, 100) grid.size = (450, 450) # 15 * 30 pixels per cell @@ -182,8 +182,8 @@ def handle_input(key, state): print(f"Reset entity to ({entity.x}, {entity.y})") # Set scene -mcrfpy.setScene("test_anim") -mcrfpy.keypressScene(handle_input) +test_anim.activate() +test_anim.on_key = handle_input # Start position update timer mcrfpy.setTimer("update_pos", update_position_display, 200) diff --git a/tests/unit/test_entity_collection_remove.py b/tests/unit/test_entity_collection_remove.py index 0ae8068..d6bbd83 100644 --- a/tests/unit/test_entity_collection_remove.py +++ b/tests/unit/test_entity_collection_remove.py @@ -12,11 +12,11 @@ def test_remove_by_entity(): # Create a test scene and grid scene_name = "test_entity_remove" - mcrfpy.createScene(scene_name) + _scene = mcrfpy.Scene(scene_name) # Create a grid (entities need a grid) grid = mcrfpy.Grid() # Default 2x2 grid is fine for testing - mcrfpy.sceneUI(scene_name).append(grid) + _scene.children.append(grid) # TODO: Replace _scene with correct Scene object # Get the entity collection entities = grid.entities diff --git a/tests/unit/test_entity_constructor.py b/tests/unit/test_entity_constructor.py index 56f9463..cf38d89 100644 --- a/tests/unit/test_entity_constructor.py +++ b/tests/unit/test_entity_constructor.py @@ -2,8 +2,8 @@ import mcrfpy # Create scene and grid -mcrfpy.createScene("test") -ui = mcrfpy.sceneUI("test") +test = mcrfpy.Scene("test") +ui = test.children # Create texture and grid texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16) diff --git a/tests/unit/test_entity_fix.py b/tests/unit/test_entity_fix.py index eef131b..6f35167 100644 --- a/tests/unit/test_entity_fix.py +++ b/tests/unit/test_entity_fix.py @@ -27,7 +27,7 @@ print("UIEntity::setProperty for 'x' and 'y' properties.") print() # Create scene to demonstrate -mcrfpy.createScene("fix_demo") +fix_demo = mcrfpy.Scene("fix_demo") # Create grid grid = mcrfpy.Grid(grid_x=15, grid_y=10) @@ -49,7 +49,7 @@ entity = mcrfpy.Entity((2, 2), grid=grid) entity.sprite_index = 64 # @ # UI -ui = mcrfpy.sceneUI("fix_demo") +ui = fix_demo.children ui.append(grid) grid.position = (100, 150) grid.size = (450, 300) @@ -111,8 +111,8 @@ def handle_input(key, state): status.text = "Reset entity to (2,2)" # Setup -mcrfpy.setScene("fix_demo") -mcrfpy.keypressScene(handle_input) +fix_demo.activate() +fix_demo.on_key = handle_input mcrfpy.setTimer("update", update_display, 100) print("Ready to demonstrate the issue.") diff --git a/tests/unit/test_entity_path_to.py b/tests/unit/test_entity_path_to.py index caeb4c1..6d3bcc8 100644 --- a/tests/unit/test_entity_path_to.py +++ b/tests/unit/test_entity_path_to.py @@ -7,7 +7,7 @@ print("Testing Entity.path_to() method...") print("=" * 50) # Create scene and grid -mcrfpy.createScene("path_test") +path_test = mcrfpy.Scene("path_test") grid = mcrfpy.Grid(grid_x=10, grid_y=10) # Set up a simple map with some walls diff --git a/tests/unit/test_entity_path_to_edge_cases.py b/tests/unit/test_entity_path_to_edge_cases.py index ef67d8f..2a3fcbd 100644 --- a/tests/unit/test_entity_path_to_edge_cases.py +++ b/tests/unit/test_entity_path_to_edge_cases.py @@ -19,7 +19,7 @@ except Exception as e: # Test 2: Entity in grid with walls blocking path print("\nTest 2: Completely blocked path") -mcrfpy.createScene("blocked_test") +blocked_test = mcrfpy.Scene("blocked_test") grid = mcrfpy.Grid(grid_x=5, grid_y=5) # Make all tiles walkable first diff --git a/tests/unit/test_exact_failure.py b/tests/unit/test_exact_failure.py index b4e5924..d4215db 100644 --- a/tests/unit/test_exact_failure.py +++ b/tests/unit/test_exact_failure.py @@ -12,7 +12,7 @@ FLOOR_COLOR = mcrfpy.Color(200, 200, 220) def test_exact_pattern(): """Exact code from dijkstra_demo_final.py""" - mcrfpy.createScene("dijkstra_demo") + dijkstra_demo = mcrfpy.Scene("dijkstra_demo") # Create grid grid = mcrfpy.Grid(grid_x=25, grid_y=15) @@ -48,7 +48,7 @@ print("Test 2: Breaking it down step by step...") # Step 1: Scene and grid try: - mcrfpy.createScene("test2") + test2 = mcrfpy.Scene("test2") grid = mcrfpy.Grid(grid_x=25, grid_y=15) print(" ✓ Step 1: Scene and grid created") except Exception as e: diff --git a/tests/unit/test_frame_clipping.py b/tests/unit/test_frame_clipping.py index 5917aca..c568a1a 100644 --- a/tests/unit/test_frame_clipping.py +++ b/tests/unit/test_frame_clipping.py @@ -22,7 +22,7 @@ def take_second_screenshot(runtime): def animate_frames(runtime): """Animate frames to demonstrate clipping""" mcrfpy.delTimer("animate") - scene = mcrfpy.sceneUI("test") + scene = test.children # Move child frames parent1 = scene[0] parent2 = scene[1] @@ -36,7 +36,7 @@ def test_clipping(runtime): print("Testing UIFrame clipping functionality...") - scene = mcrfpy.sceneUI("test") + scene = test.children # Create parent frame with clipping disabled (default) parent1 = Frame(pos=(50, 50), size=(200, 150), @@ -119,15 +119,15 @@ def test_clipping(runtime): def handle_keypress(key, modifiers): if key == "c": - scene = mcrfpy.sceneUI("test") + scene = test.children parent1 = scene[0] parent1.clip_children = not parent1.clip_children print(f"Toggled parent1 clip_children to: {parent1.clip_children}") # Main execution print("Creating test scene...") -mcrfpy.createScene("test") -mcrfpy.setScene("test") -mcrfpy.keypressScene(handle_keypress) +test = mcrfpy.Scene("test") +test.activate() +test.on_key = handle_keypress mcrfpy.setTimer("test_clipping", test_clipping, 100) print("Test scheduled, running...") diff --git a/tests/unit/test_frame_clipping_advanced.py b/tests/unit/test_frame_clipping_advanced.py index b7e9a33..2b50e02 100644 --- a/tests/unit/test_frame_clipping_advanced.py +++ b/tests/unit/test_frame_clipping_advanced.py @@ -12,7 +12,7 @@ def test_nested_clipping(runtime): print("Testing advanced UIFrame clipping with nested frames...") # Create test scene - scene = mcrfpy.sceneUI("test") + scene = test.children # Create outer frame with clipping enabled outer = Frame(pos=(50, 50), size=(400, 300), @@ -94,8 +94,8 @@ def test_nested_clipping(runtime): # Main execution print("Creating advanced test scene...") -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule the test mcrfpy.setTimer("test_nested_clipping", test_nested_clipping, 100) diff --git a/tests/unit/test_grid_background.py b/tests/unit/test_grid_background.py index b74daf4..4fee8b9 100644 --- a/tests/unit/test_grid_background.py +++ b/tests/unit/test_grid_background.py @@ -9,8 +9,8 @@ def test_grid_background(): print("Testing Grid Background Color...") # Create a test scene - mcrfpy.createScene("test") - ui = mcrfpy.sceneUI("test") + test = mcrfpy.Scene("test") + ui = test.children # Create a grid with default background grid = mcrfpy.Grid(pos=(50, 50), size=(400, 300), grid_size=(20, 15)) @@ -40,7 +40,7 @@ def test_grid_background(): info_frame.children.append(color_display) # Activate the scene - mcrfpy.setScene("test") + test.activate() def run_tests(dt): """Run background color tests""" diff --git a/tests/unit/test_grid_cell_events.py b/tests/unit/test_grid_cell_events.py index f367fbf..9620d51 100644 --- a/tests/unit/test_grid_cell_events.py +++ b/tests/unit/test_grid_cell_events.py @@ -9,8 +9,8 @@ def test_properties(): """Test grid cell event properties exist and work""" print("Testing grid cell event properties...") - mcrfpy.createScene("test_props") - ui = mcrfpy.sceneUI("test_props") + test_props = mcrfpy.Scene("test_props") + ui = test_props.children grid = mcrfpy.Grid(grid_size=(5, 5), pos=(100, 100), size=(200, 200)) ui.append(grid) @@ -45,9 +45,9 @@ def test_cell_hover(): """Test cell hover events""" print("Testing cell hover events...") - mcrfpy.createScene("test_hover") - ui = mcrfpy.sceneUI("test_hover") - mcrfpy.setScene("test_hover") + test_hover = mcrfpy.Scene("test_hover") + ui = test_hover.children + test_hover.activate() grid = mcrfpy.Grid(grid_size=(5, 5), pos=(100, 100), size=(200, 200)) ui.append(grid) @@ -89,9 +89,9 @@ def test_cell_click(): """Test cell click events""" print("Testing cell click events...") - mcrfpy.createScene("test_click") - ui = mcrfpy.sceneUI("test_click") - mcrfpy.setScene("test_click") + test_click = mcrfpy.Scene("test_click") + ui = test_click.children + test_click.activate() grid = mcrfpy.Grid(grid_size=(5, 5), pos=(100, 100), size=(200, 200)) ui.append(grid) diff --git a/tests/unit/test_grid_children.py b/tests/unit/test_grid_children.py index 5615886..26f7f39 100644 --- a/tests/unit/test_grid_children.py +++ b/tests/unit/test_grid_children.py @@ -18,7 +18,7 @@ def run_test(runtime): mcrfpy.delTimer("test") # Get the scene UI - ui = mcrfpy.sceneUI("test") + ui = test.children # Create a grid without texture (uses default 16x16 cells) print("Test 1: Creating Grid with children...") @@ -122,8 +122,8 @@ def run_test(runtime): mcrfpy.setTimer("screenshot", take_screenshot, 100) # Create a test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 50) diff --git a/tests/unit/test_grid_creation.py b/tests/unit/test_grid_creation.py index c4d0b59..3f37b36 100644 --- a/tests/unit/test_grid_creation.py +++ b/tests/unit/test_grid_creation.py @@ -8,7 +8,7 @@ print("Testing grid creation...") # First create scene try: - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") print("✓ Created scene") except Exception as e: print(f"✗ Failed to create scene: {e}") diff --git a/tests/unit/test_grid_error.py b/tests/unit/test_grid_error.py index fdbfb51..0b437ba 100644 --- a/tests/unit/test_grid_error.py +++ b/tests/unit/test_grid_error.py @@ -8,7 +8,7 @@ import traceback print("Testing grid creation with detailed error...") # Create scene first -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") # Try to create grid and get detailed error try: diff --git a/tests/unit/test_grid_iteration.py b/tests/unit/test_grid_iteration.py index 4a80e0c..218ab85 100644 --- a/tests/unit/test_grid_iteration.py +++ b/tests/unit/test_grid_iteration.py @@ -9,7 +9,7 @@ print("=" * 50) # Test 1: Basic grid.at() calls print("Test 1: Basic grid.at() calls") try: - mcrfpy.createScene("test1") + test1 = mcrfpy.Scene("test1") grid = mcrfpy.Grid(grid_x=5, grid_y=5) # Single call @@ -32,7 +32,7 @@ print() # Test 2: Grid.at() in a loop print("Test 2: Grid.at() in simple loop") try: - mcrfpy.createScene("test2") + test2 = mcrfpy.Scene("test2") grid = mcrfpy.Grid(grid_x=5, grid_y=5) for i in range(3): @@ -50,7 +50,7 @@ print() # Test 3: Nested loops with grid.at() print("Test 3: Nested loops with grid.at()") try: - mcrfpy.createScene("test3") + test3 = mcrfpy.Scene("test3") grid = mcrfpy.Grid(grid_x=5, grid_y=5) for y in range(3): @@ -68,7 +68,7 @@ print() # Test 4: Exact pattern from failing code print("Test 4: Exact failing pattern") try: - mcrfpy.createScene("test4") + test4 = mcrfpy.Scene("test4") grid = mcrfpy.Grid(grid_x=25, grid_y=15) grid.fill_color = mcrfpy.Color(0, 0, 0) @@ -109,7 +109,7 @@ print() # Test 5: Is it related to the number of grid.at() calls? print("Test 5: Testing grid.at() call limits") try: - mcrfpy.createScene("test5") + test5 = mcrfpy.Scene("test5") grid = mcrfpy.Grid(grid_x=10, grid_y=10) count = 0 diff --git a/tests/unit/test_headless_benchmark.py b/tests/unit/test_headless_benchmark.py index c6f328e..898dc58 100644 --- a/tests/unit/test_headless_benchmark.py +++ b/tests/unit/test_headless_benchmark.py @@ -17,9 +17,9 @@ def run_tests(): print("=== Headless Benchmark Tests ===\n") # Create a test scene - mcrfpy.createScene("benchmark_test") - mcrfpy.setScene("benchmark_test") - ui = mcrfpy.sceneUI("benchmark_test") + benchmark_test = mcrfpy.Scene("benchmark_test") + benchmark_test.activate() + ui = benchmark_test.children # Add some UI elements to have something to render frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) diff --git a/tests/unit/test_headless_click.py b/tests/unit/test_headless_click.py index eaddec1..5078bed 100644 --- a/tests/unit/test_headless_click.py +++ b/tests/unit/test_headless_click.py @@ -13,9 +13,9 @@ def test_headless_click(): """Test that clicks work in headless mode via automation API""" print("Testing headless click events...") - mcrfpy.createScene("test_click") - ui = mcrfpy.sceneUI("test_click") - mcrfpy.setScene("test_click") + test_click = mcrfpy.Scene("test_click") + ui = test_click.children + test_click.activate() # Create a frame at known position frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) @@ -64,9 +64,9 @@ def test_click_miss(): click_count = 0 click_positions = [] - mcrfpy.createScene("test_miss") - ui = mcrfpy.sceneUI("test_miss") - mcrfpy.setScene("test_miss") + test_miss = mcrfpy.Scene("test_miss") + ui = test_miss.children + test_miss.activate() # Create a frame at known position frame = mcrfpy.Frame(pos=(100, 100), size=(100, 100)) diff --git a/tests/unit/test_headless_detection.py b/tests/unit/test_headless_detection.py index babe65d..658d93b 100644 --- a/tests/unit/test_headless_detection.py +++ b/tests/unit/test_headless_detection.py @@ -6,9 +6,9 @@ from mcrfpy import automation import sys # Create scene -mcrfpy.createScene("detect_test") -ui = mcrfpy.sceneUI("detect_test") -mcrfpy.setScene("detect_test") +detect_test = mcrfpy.Scene("detect_test") +ui = detect_test.children +detect_test.activate() # Create a frame frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) diff --git a/tests/unit/test_headless_modes.py b/tests/unit/test_headless_modes.py index 3e36658..ab80a4f 100644 --- a/tests/unit/test_headless_modes.py +++ b/tests/unit/test_headless_modes.py @@ -5,9 +5,9 @@ import mcrfpy import sys # Create scene -mcrfpy.createScene("headless_test") -ui = mcrfpy.sceneUI("headless_test") -mcrfpy.setScene("headless_test") +headless_test = mcrfpy.Scene("headless_test") +ui = headless_test.children +headless_test.activate() # Create a visible indicator frame = mcrfpy.Frame(pos=(200, 200), size=(400, 200)) diff --git a/tests/unit/test_metrics.py b/tests/unit/test_metrics.py index 885e2c5..06b6f24 100644 --- a/tests/unit/test_metrics.py +++ b/tests/unit/test_metrics.py @@ -108,11 +108,11 @@ def test_metrics(runtime): # Set up test scene print("Setting up metrics test scene...") -mcrfpy.createScene("metrics_test") -mcrfpy.setScene("metrics_test") +metrics_test = mcrfpy.Scene("metrics_test") +metrics_test.activate() # Add some UI elements -ui = mcrfpy.sceneUI("metrics_test") +ui = metrics_test.children # Create various UI elements frame1 = mcrfpy.Frame(pos=(10, 10), size=(200, 150)) diff --git a/tests/unit/test_mouse_enter_exit.py b/tests/unit/test_mouse_enter_exit.py index eb033a8..c2fa7a4 100644 --- a/tests/unit/test_mouse_enter_exit.py +++ b/tests/unit/test_mouse_enter_exit.py @@ -15,8 +15,8 @@ def test_callback_assignment(): """Test that on_enter and on_exit callbacks can be assigned""" print("Testing callback assignment...") - mcrfpy.createScene("test_assign") - ui = mcrfpy.sceneUI("test_assign") + test_assign = mcrfpy.Scene("test_assign") + ui = test_assign.children frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) ui.append(frame) @@ -50,8 +50,8 @@ def test_hovered_property(): """Test that hovered property exists and is initially False""" print("Testing hovered property...") - mcrfpy.createScene("test_hovered") - ui = mcrfpy.sceneUI("test_hovered") + test_hovered = mcrfpy.Scene("test_hovered") + ui = test_hovered.children frame = mcrfpy.Frame(pos=(50, 50), size=(100, 100)) ui.append(frame) @@ -77,8 +77,8 @@ def test_all_types_have_events(): """Test that all drawable types have on_enter/on_exit properties""" print("Testing events on all drawable types...") - mcrfpy.createScene("test_types") - ui = mcrfpy.sceneUI("test_types") + test_types = mcrfpy.Scene("test_types") + ui = test_types.children types_to_test = [ ("Frame", mcrfpy.Frame(pos=(0, 0), size=(100, 100))), @@ -121,9 +121,9 @@ def test_enter_exit_simulation(): enter_positions = [] exit_positions = [] - mcrfpy.createScene("test_sim") - ui = mcrfpy.sceneUI("test_sim") - mcrfpy.setScene("test_sim") + test_sim = mcrfpy.Scene("test_sim") + ui = test_sim.children + test_sim.activate() # Create a frame at known position frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) diff --git a/tests/unit/test_no_arg_constructors.py b/tests/unit/test_no_arg_constructors.py index b5f18a8..238d136 100644 --- a/tests/unit/test_no_arg_constructors.py +++ b/tests/unit/test_no_arg_constructors.py @@ -85,7 +85,7 @@ def test_ui_constructors(runtime): sys.exit(0) # Create a basic scene so the game can start -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") # Schedule the test to run after game initialization mcrfpy.setTimer("test", test_ui_constructors, 100) \ No newline at end of file diff --git a/tests/unit/test_on_move.py b/tests/unit/test_on_move.py index b1e78e7..957c1a7 100644 --- a/tests/unit/test_on_move.py +++ b/tests/unit/test_on_move.py @@ -9,8 +9,8 @@ def test_on_move_property(): """Test that on_move property exists and can be assigned""" print("Testing on_move property...") - mcrfpy.createScene("test_move_prop") - ui = mcrfpy.sceneUI("test_move_prop") + test_move_prop = mcrfpy.Scene("test_move_prop") + ui = test_move_prop.children frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) ui.append(frame) @@ -33,9 +33,9 @@ def test_on_move_fires(): """Test that on_move fires when mouse moves within bounds""" print("Testing on_move callback firing...") - mcrfpy.createScene("test_move") - ui = mcrfpy.sceneUI("test_move") - mcrfpy.setScene("test_move") + test_move = mcrfpy.Scene("test_move") + ui = test_move.children + test_move.activate() # Create a frame at known position frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) @@ -78,9 +78,9 @@ def test_on_move_not_outside(): """Test that on_move doesn't fire when mouse is outside bounds""" print("Testing on_move doesn't fire outside bounds...") - mcrfpy.createScene("test_move_outside") - ui = mcrfpy.sceneUI("test_move_outside") - mcrfpy.setScene("test_move_outside") + test_move_outside = mcrfpy.Scene("test_move_outside") + ui = test_move_outside.children + test_move_outside.activate() # Frame at 100-300, 100-300 frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) @@ -117,8 +117,8 @@ def test_all_types_have_on_move(): """Test that all drawable types have on_move property""" print("Testing on_move on all drawable types...") - mcrfpy.createScene("test_types") - ui = mcrfpy.sceneUI("test_types") + test_types = mcrfpy.Scene("test_types") + ui = test_types.children types_to_test = [ ("Frame", mcrfpy.Frame(pos=(0, 0), size=(100, 100))), diff --git a/tests/unit/test_oneline_for.py b/tests/unit/test_oneline_for.py index 94e336b..6ba30e1 100644 --- a/tests/unit/test_oneline_for.py +++ b/tests/unit/test_oneline_for.py @@ -47,7 +47,7 @@ print() # Test 4: After creating mcrfpy objects print("Test 4: After creating mcrfpy scene/grid") try: - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") grid = mcrfpy.Grid(grid_x=10, grid_y=10) walls = [] @@ -63,7 +63,7 @@ print() # Test 5: Check line number in error print("Test 5: Checking exact error location") def test_exact_pattern(): - mcrfpy.createScene("dijkstra_demo") + dijkstra_demo = mcrfpy.Scene("dijkstra_demo") grid = mcrfpy.Grid(grid_x=25, grid_y=15) grid.fill_color = mcrfpy.Color(0, 0, 0) diff --git a/tests/unit/test_parent_child_system.py b/tests/unit/test_parent_child_system.py index 2cdd4c9..3f2d6dd 100644 --- a/tests/unit/test_parent_child_system.py +++ b/tests/unit/test_parent_child_system.py @@ -13,8 +13,8 @@ def test_parent_property(): print("Testing parent property...") # Create scene and get UI - mcrfpy.createScene("test") - ui = mcrfpy.sceneUI("test") + test = mcrfpy.Scene("test") + ui = test.children # Create a parent frame parent = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) @@ -44,8 +44,8 @@ def test_global_position(): print("Testing global_position property...") # Create scene and get UI - mcrfpy.createScene("test2") - ui = mcrfpy.sceneUI("test2") + test2 = mcrfpy.Scene("test2") + ui = test2.children # Create nested hierarchy: # root (50, 50) @@ -81,8 +81,8 @@ def test_parent_changes_on_move(): """Test that moving child to different parent updates parent reference""" print("Testing parent changes on move...") - mcrfpy.createScene("test3") - ui = mcrfpy.sceneUI("test3") + test3 = mcrfpy.Scene("test3") + ui = test3.children parent1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100), fill_color=(255, 0, 0, 255)) parent2 = mcrfpy.Frame(pos=(200, 0), size=(100, 100), fill_color=(0, 255, 0, 255)) @@ -116,8 +116,8 @@ def test_remove_clears_parent(): """Test that removing child clears parent reference""" print("Testing remove clears parent...") - mcrfpy.createScene("test4") - ui = mcrfpy.sceneUI("test4") + test4 = mcrfpy.Scene("test4") + ui = test4.children parent = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) ui.append(parent) @@ -140,8 +140,8 @@ def test_scene_level_elements(): """Test that scene-level elements have no parent""" print("Testing scene-level elements...") - mcrfpy.createScene("test5") - ui = mcrfpy.sceneUI("test5") + test5 = mcrfpy.Scene("test5") + ui = test5.children frame = mcrfpy.Frame(pos=(10, 10), size=(50, 50)) ui.append(frame) @@ -160,8 +160,8 @@ def test_all_drawable_types(): """Test parent/global_position on all drawable types""" print("Testing all drawable types...") - mcrfpy.createScene("test6") - ui = mcrfpy.sceneUI("test6") + test6 = mcrfpy.Scene("test6") + ui = test6.children parent = mcrfpy.Frame(pos=(100, 100), size=(300, 300)) ui.append(parent) @@ -190,8 +190,8 @@ def test_parent_setter(): """Test parent property setter (assign parent directly)""" print("Testing parent setter...") - mcrfpy.createScene("test7") - ui = mcrfpy.sceneUI("test7") + test7 = mcrfpy.Scene("test7") + ui = test7.children # Create parent frame and child parent = mcrfpy.Frame(pos=(100, 100), size=(200, 200)) @@ -223,8 +223,8 @@ def test_reparenting_via_setter(): """Test moving a child from one parent to another via setter""" print("Testing reparenting via setter...") - mcrfpy.createScene("test8") - ui = mcrfpy.sceneUI("test8") + test8 = mcrfpy.Scene("test8") + ui = test8.children parent1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100)) parent2 = mcrfpy.Frame(pos=(200, 200), size=(100, 100)) diff --git a/tests/unit/test_path_colors.py b/tests/unit/test_path_colors.py index 1bcd9cd..0a95932 100644 --- a/tests/unit/test_path_colors.py +++ b/tests/unit/test_path_colors.py @@ -8,7 +8,7 @@ print("Testing path color changes...") print("=" * 50) # Create scene and small grid -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") grid = mcrfpy.Grid(grid_x=5, grid_y=5) # Add color layer for cell coloring @@ -75,12 +75,12 @@ def check_visual(runtime): sys.exit(0) # Set up minimal UI to test rendering -ui = mcrfpy.sceneUI("test") +ui = test.children ui.append(grid) grid.position = (50, 50) grid.size = (250, 250) -mcrfpy.setScene("test") +test.activate() mcrfpy.setTimer("check", check_visual, 500) print("\nStarting render test...") \ No newline at end of file diff --git a/tests/unit/test_pathfinding_integration.py b/tests/unit/test_pathfinding_integration.py index a27f6a5..a5d3836 100644 --- a/tests/unit/test_pathfinding_integration.py +++ b/tests/unit/test_pathfinding_integration.py @@ -8,7 +8,7 @@ print("Testing pathfinding integration...") print("=" * 50) # Create scene and grid -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") grid = mcrfpy.Grid(grid_x=10, grid_y=10) # Initialize grid diff --git a/tests/unit/test_profiler_quick.py b/tests/unit/test_profiler_quick.py index 2aa5265..5ab0a2b 100644 --- a/tests/unit/test_profiler_quick.py +++ b/tests/unit/test_profiler_quick.py @@ -5,9 +5,9 @@ import mcrfpy import sys # Create a simple scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") -ui = mcrfpy.sceneUI("test") +test = mcrfpy.Scene("test") +test.activate() +ui = test.children # Create a small grid grid = mcrfpy.Grid( diff --git a/tests/unit/test_properties_quick.py b/tests/unit/test_properties_quick.py index e16774a..1a6bb69 100644 --- a/tests/unit/test_properties_quick.py +++ b/tests/unit/test_properties_quick.py @@ -53,5 +53,5 @@ def test_properties(runtime): sys.exit(0) -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") mcrfpy.setTimer("test_properties", test_properties, 100) \ No newline at end of file diff --git a/tests/unit/test_python_object_cache.py b/tests/unit/test_python_object_cache.py index e7c2831..6d882f5 100644 --- a/tests/unit/test_python_object_cache.py +++ b/tests/unit/test_python_object_cache.py @@ -36,7 +36,7 @@ def run_tests(runtime): # Test 2: Create instance and add to scene frame = MyFrame(50, 50) - scene_ui = mcrfpy.sceneUI("test_scene") + scene_ui = test_scene.children scene_ui.append(frame) # Test 3: Retrieve from collection and check type @@ -142,8 +142,8 @@ def run_tests(runtime): sys.exit(0 if test_passed else 1) # Create test scene -mcrfpy.createScene("test_scene") -mcrfpy.setScene("test_scene") +test_scene = mcrfpy.Scene("test_scene") +test_scene.activate() # Schedule tests to run after game loop starts mcrfpy.setTimer("test", run_tests, 100) diff --git a/tests/unit/test_range_25_bug.py b/tests/unit/test_range_25_bug.py index 2d5826a..3dc051d 100644 --- a/tests/unit/test_range_25_bug.py +++ b/tests/unit/test_range_25_bug.py @@ -18,7 +18,7 @@ except Exception as e: # Test 2: range(25) after creating scene/grid print("\nTest 2: range(25) after creating 25x15 grid") try: - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") grid = mcrfpy.Grid(grid_x=25, grid_y=15) for i in range(25): @@ -30,7 +30,7 @@ except Exception as e: # Test 3: The killer combination print("\nTest 3: range(25) after 15x25 grid.at() operations") try: - mcrfpy.createScene("test3") + test3 = mcrfpy.Scene("test3") grid = mcrfpy.Grid(grid_x=25, grid_y=15) # Do the nested loop that triggers the bug @@ -54,7 +54,7 @@ except Exception as e: # Test 4: Does range(24) still work? print("\nTest 4: range(24) after same operations") try: - mcrfpy.createScene("test4") + test4 = mcrfpy.Scene("test4") grid = mcrfpy.Grid(grid_x=25, grid_y=15) for y in range(15): @@ -76,7 +76,7 @@ except Exception as e: # Test 5: Is it about the specific combination of 15 and 25? print("\nTest 5: Different grid dimensions") try: - mcrfpy.createScene("test5") + test5 = mcrfpy.Scene("test5") grid = mcrfpy.Grid(grid_x=30, grid_y=20) for y in range(20): diff --git a/tests/unit/test_range_threshold.py b/tests/unit/test_range_threshold.py index c1737f2..fd04a19 100644 --- a/tests/unit/test_range_threshold.py +++ b/tests/unit/test_range_threshold.py @@ -69,7 +69,7 @@ print("Testing if it's about grid size vs range size...") try: # Small grid, large range - mcrfpy.createScene("test_small_grid") + test_small_grid = mcrfpy.Scene("test_small_grid") grid = mcrfpy.Grid(grid_x=5, grid_y=5) # Do minimal grid operations @@ -85,7 +85,7 @@ except Exception as e: try: # Large grid, see what happens - mcrfpy.createScene("test_large_grid") + test_large_grid = mcrfpy.Scene("test_large_grid") grid = mcrfpy.Grid(grid_x=20, grid_y=20) # Do operations on large grid diff --git a/tests/unit/test_scene_properties.py b/tests/unit/test_scene_properties.py index 9557e54..cf31590 100644 --- a/tests/unit/test_scene_properties.py +++ b/tests/unit/test_scene_properties.py @@ -4,7 +4,7 @@ import mcrfpy import sys # Create test scenes -mcrfpy.createScene("test_scene") +test_scene = mcrfpy.Scene("test_scene") def test_scene_pos(): """Test Scene pos property""" diff --git a/tests/unit/test_scene_transitions.py b/tests/unit/test_scene_transitions.py index ea541b6..efd23c7 100644 --- a/tests/unit/test_scene_transitions.py +++ b/tests/unit/test_scene_transitions.py @@ -5,56 +5,58 @@ import mcrfpy import sys import time +red_scene, blue_scene, green_scene, menu_scene = None, None, None, None # global scoping + def create_test_scenes(): """Create several test scenes with different colored backgrounds.""" - + global red_scene, blue_scene, green_scene, menu_scene # Scene 1: Red background - mcrfpy.createScene("red_scene") - ui1 = mcrfpy.sceneUI("red_scene") + red_scene = mcrfpy.Scene("red_scene") + ui1 = red_scene.children bg1 = mcrfpy.Frame(pos=(0, 0), size=(1024, 768), fill_color=mcrfpy.Color(255, 0, 0, 255)) - label1 = mcrfpy.Caption(pos=(512, 384), text="RED SCENE", font=mcrfpy.Font.font_ui) + label1 = mcrfpy.Caption(pos=(512, 384), text="RED SCENE", font=mcrfpy.default_font) label1.fill_color = mcrfpy.Color(255, 255, 255, 255) ui1.append(bg1) ui1.append(label1) # Scene 2: Blue background - mcrfpy.createScene("blue_scene") - ui2 = mcrfpy.sceneUI("blue_scene") + blue_scene = mcrfpy.Scene("blue_scene") + ui2 = blue_scene.children bg2 = mcrfpy.Frame(pos=(0, 0), size=(1024, 768), fill_color=mcrfpy.Color(0, 0, 255, 255)) - label2 = mcrfpy.Caption(pos=(512, 384), text="BLUE SCENE", font=mcrfpy.Font.font_ui) + label2 = mcrfpy.Caption(pos=(512, 384), text="BLUE SCENE", font=mcrfpy.default_font) label2.fill_color = mcrfpy.Color(255, 255, 255, 255) ui2.append(bg2) ui2.append(label2) # Scene 3: Green background - mcrfpy.createScene("green_scene") - ui3 = mcrfpy.sceneUI("green_scene") + green_scene = mcrfpy.Scene("green_scene") + ui3 = green_scene.children bg3 = mcrfpy.Frame(pos=(0, 0), size=(1024, 768), fill_color=mcrfpy.Color(0, 255, 0, 255)) - label3 = mcrfpy.Caption(pos=(512, 384), text="GREEN SCENE", font=mcrfpy.Font.font_ui) + label3 = mcrfpy.Caption(pos=(512, 384), text="GREEN SCENE", font=mcrfpy.default_font) label3.fill_color = mcrfpy.Color(0, 0, 0, 255) # Black text on green ui3.append(bg3) ui3.append(label3) # Scene 4: Menu scene with buttons - mcrfpy.createScene("menu_scene") - ui4 = mcrfpy.sceneUI("menu_scene") + menu_scene = mcrfpy.Scene("menu_scene") + ui4 = menu_scene.children bg4 = mcrfpy.Frame(pos=(0, 0), size=(1024, 768), fill_color=mcrfpy.Color(50, 50, 50, 255)) - title = mcrfpy.Caption(pos=(512, 100), text="SCENE TRANSITION DEMO", font=mcrfpy.Font.font_ui) + title = mcrfpy.Caption(pos=(512, 100), text="SCENE TRANSITION DEMO", font=mcrfpy.default_font) title.fill_color = mcrfpy.Color(255, 255, 255, 255) ui4.append(bg4) ui4.append(title) # Add instruction text - instructions = mcrfpy.Caption(pos=(512, 200), text="Press keys 1-6 for different transitions", font=mcrfpy.Font.font_ui) + instructions = mcrfpy.Caption(pos=(512, 200), text="Press keys 1-6 for different transitions", font=mcrfpy.default_font) instructions.fill_color = mcrfpy.Color(200, 200, 200, 255) ui4.append(instructions) - controls = mcrfpy.Caption(pos=(512, 250), text="1: Fade | 2: Slide Left | 3: Slide Right | 4: Slide Up | 5: Slide Down | 6: Instant", font=mcrfpy.Font.font_ui) + controls = mcrfpy.Caption(pos=(512, 250), text="1: Fade | 2: Slide Left | 3: Slide Right | 4: Slide Up | 5: Slide Down | 6: Instant", font=mcrfpy.default_font) controls.fill_color = mcrfpy.Color(150, 150, 150, 255) ui4.append(controls) - scene_info = mcrfpy.Caption(pos=(512, 300), text="R: Red Scene | B: Blue Scene | G: Green Scene | M: Menu", font=mcrfpy.Font.font_ui) + scene_info = mcrfpy.Caption(pos=(512, 300), text="R: Red Scene | B: Blue Scene | G: Green Scene | M: Menu", font=mcrfpy.default_font) scene_info.fill_color = mcrfpy.Color(150, 150, 150, 255) ui4.append(scene_info) @@ -71,7 +73,7 @@ def handle_key(key, action): if action != "start": return - current_scene = mcrfpy.currentScene() + current_scene = (mcrfpy.current_scene.name if mcrfpy.current_scene else None) # Number keys set transition type if key == "Num1": @@ -94,34 +96,43 @@ def handle_key(key, action): print("Transition set to: instant") # Letter keys change scene - elif key == "R": - if current_scene != "red_scene": - print(f"Transitioning to red_scene with {current_transition}") - if current_transition: - mcrfpy.setScene("red_scene", current_transition, transition_duration) - else: - mcrfpy.setScene("red_scene") - elif key == "B": - if current_scene != "blue_scene": - print(f"Transitioning to blue_scene with {current_transition}") - if current_transition: - mcrfpy.setScene("blue_scene", current_transition, transition_duration) - else: - mcrfpy.setScene("blue_scene") - elif key == "G": - if current_scene != "green_scene": - print(f"Transitioning to green_scene with {current_transition}") - if current_transition: - mcrfpy.setScene("green_scene", current_transition, transition_duration) - else: - mcrfpy.setScene("green_scene") - elif key == "M": - if current_scene != "menu_scene": - print(f"Transitioning to menu_scene with {current_transition}") - if current_transition: - mcrfpy.setScene("menu_scene", current_transition, transition_duration) - else: - mcrfpy.setScene("menu_scene") + keytransitions = { + "R": red_scene, + "B": blue_scene, + "G": green_scene, + "M": menu_scene + } + if key in keytransitions: + if mcrfpy.current_scene != keytransitions[key]: + keytransitions[key].activate() + #elif key == "R": + # if current_scene != "red_scene": + # print(f"Transitioning to red_scene with {current_transition}") + # if current_transition: + # mcrfpy.setScene("red_scene", current_transition, transition_duration) + # else: + # red_scene.activate() + #elif key == "B": + # if current_scene != "blue_scene": + # print(f"Transitioning to blue_scene with {current_transition}") + # if current_transition: + # mcrfpy.setScene("blue_scene", current_transition, transition_duration) + # else: + # blue_scene.activate() + #elif key == "G": + # if current_scene != "green_scene": + # print(f"Transitioning to green_scene with {current_transition}") + # if current_transition: + # mcrfpy.setScene("green_scene", current_transition, transition_duration) + # else: + # green_scene.activate() + #elif key == "M": + # if current_scene != "menu_scene": + # print(f"Transitioning to menu_scene with {current_transition}") + # if current_transition: + # mcrfpy.setScene("menu_scene", current_transition, transition_duration) + # else: + # menu_scene.activate() elif key == "Escape": print("Exiting...") sys.exit(0) @@ -144,7 +155,7 @@ def test_automatic_transitions(delay): mcrfpy.setScene(scene, trans_type, 1.0) else: print(f"Transition {i+1}: instant to {scene}") - mcrfpy.setScene(scene) + mcrfpy.current_scene = scene time.sleep(2) # Wait for transition to complete plus viewing time print("Automatic test complete!") @@ -155,14 +166,16 @@ print("=== Scene Transition Test ===") create_test_scenes() # Start with menu scene -mcrfpy.setScene("menu_scene") +menu_scene.activate() # Set up keyboard handler -mcrfpy.keypressScene(handle_key) +for s in (red_scene, blue_scene, green_scene, menu_scene): + s.on_key = handle_key +#menu_scene.on_key = handle_key # Option to run automatic test if len(sys.argv) > 1 and sys.argv[1] == "--auto": mcrfpy.setTimer("auto_test", test_automatic_transitions, 1000) else: print("\nManual test mode. Use keyboard controls shown on screen.") - print("Run with --auto flag for automatic transition demo.") \ No newline at end of file + print("Run with --auto flag for automatic transition demo.") diff --git a/tests/unit/test_scene_transitions_headless.py b/tests/unit/test_scene_transitions_headless.py index 1e9b571..f8b79bc 100644 --- a/tests/unit/test_scene_transitions_headless.py +++ b/tests/unit/test_scene_transitions_headless.py @@ -11,14 +11,14 @@ def test_scene_transitions(): print("Creating test scenes...") # Scene 1 - mcrfpy.createScene("scene1") - ui1 = mcrfpy.sceneUI("scene1") + scene1 = mcrfpy.Scene("scene1") + ui1 = scene1.children frame1 = mcrfpy.Frame(pos=(0, 0), size=(100, 100), fill_color=mcrfpy.Color(255, 0, 0)) ui1.append(frame1) # Scene 2 - mcrfpy.createScene("scene2") - ui2 = mcrfpy.sceneUI("scene2") + scene2 = mcrfpy.Scene("scene2") + ui2 = scene2.children frame2 = mcrfpy.Frame(pos=(0, 0), size=(100, 100), fill_color=mcrfpy.Color(0, 0, 255)) ui2.append(frame2) @@ -35,20 +35,20 @@ def test_scene_transitions(): print("\nTesting scene transitions:") # Start with scene1 - mcrfpy.setScene("scene1") - print(f"Initial scene: {mcrfpy.currentScene()}") + scene1.activate() + print(f"Initial scene: {(mcrfpy.current_scene.name if mcrfpy.current_scene else None)}") for trans_type, duration in transitions: - target = "scene2" if mcrfpy.currentScene() == "scene1" else "scene1" + target = "scene2" if (mcrfpy.current_scene.name if mcrfpy.current_scene else None) == "scene1" else "scene1" if trans_type: print(f"\nTransitioning to {target} with {trans_type} (duration: {duration}s)") mcrfpy.setScene(target, trans_type, duration) else: print(f"\nTransitioning to {target} instantly") - mcrfpy.setScene(target) + mcrfpy.current_scene = target - print(f"Current scene after transition: {mcrfpy.currentScene()}") + print(f"Current scene after transition: {(mcrfpy.current_scene.name if mcrfpy.current_scene else None)}") print("\n✓ All scene transition types tested successfully!") print("\nNote: Visual transitions cannot be verified in headless mode.") diff --git a/tests/unit/test_simple_callback.py b/tests/unit/test_simple_callback.py index 307cb9d..5e6aa47 100644 --- a/tests/unit/test_simple_callback.py +++ b/tests/unit/test_simple_callback.py @@ -6,8 +6,8 @@ import sys def cb(a, t): print("CB") -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() e = mcrfpy.Entity((0, 0), texture=None, sprite_index=0) a = mcrfpy.Animation("x", 1.0, 0.1, "linear", callback=cb) a.start(e) diff --git a/tests/unit/test_simple_drawable.py b/tests/unit/test_simple_drawable.py index 8a03baf..5943b36 100644 --- a/tests/unit/test_simple_drawable.py +++ b/tests/unit/test_simple_drawable.py @@ -26,5 +26,5 @@ def simple_test(runtime): sys.exit(0) -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") mcrfpy.setTimer("simple_test", simple_test, 100) \ No newline at end of file diff --git a/tests/unit/test_stdin_theory.py b/tests/unit/test_stdin_theory.py index 88d1d28..ad1120d 100644 --- a/tests/unit/test_stdin_theory.py +++ b/tests/unit/test_stdin_theory.py @@ -9,8 +9,8 @@ print(f"stdin.isatty(): {sys.stdin.isatty()}") print(f"stdin fileno: {sys.stdin.fileno()}") # Set up a basic scene -mcrfpy.createScene("stdin_test") -mcrfpy.setScene("stdin_test") +stdin_test = mcrfpy.Scene("stdin_test") +stdin_test.activate() # Try to prevent interactive mode by closing stdin print("\nAttempting to prevent interactive mode...") diff --git a/tests/unit/test_step_function.py b/tests/unit/test_step_function.py index 1db5b52..d92a4e4 100644 --- a/tests/unit/test_step_function.py +++ b/tests/unit/test_step_function.py @@ -108,8 +108,8 @@ def run_tests(): if __name__ == "__main__": try: # Create a scene for the test - mcrfpy.createScene("test_step") - mcrfpy.setScene("test_step") + test_step = mcrfpy.Scene("test_step") + test_step.activate() if run_tests(): print("\nPASS") diff --git a/tests/unit/test_synchronous_screenshot.py b/tests/unit/test_synchronous_screenshot.py index 9e3bc2f..45d0df7 100644 --- a/tests/unit/test_synchronous_screenshot.py +++ b/tests/unit/test_synchronous_screenshot.py @@ -22,9 +22,9 @@ def run_tests(): print("=== Synchronous Screenshot Tests ===\n") # Create a test scene with UI elements - mcrfpy.createScene("screenshot_test") - mcrfpy.setScene("screenshot_test") - ui = mcrfpy.sceneUI("screenshot_test") + screenshot_test = mcrfpy.Scene("screenshot_test") + screenshot_test.activate() + ui = screenshot_test.children # Test 1: Basic screenshot works print("Test 1: Basic screenshot functionality") diff --git a/tests/unit/test_tcod_complete.py b/tests/unit/test_tcod_complete.py index 21934ab..eba8577 100644 --- a/tests/unit/test_tcod_complete.py +++ b/tests/unit/test_tcod_complete.py @@ -9,7 +9,7 @@ def run_tests(): # Test 1: Basic Grid Creation print("Test 1: Grid Creation") - mcrfpy.createScene("tcod_test") + tcod_test = mcrfpy.Scene("tcod_test") grid = mcrfpy.Grid(grid_x=10, grid_y=10, texture=None, pos=(10, 10), size=(160, 160)) print("✓ Grid created successfully\n") diff --git a/tests/unit/test_tcod_fov.py b/tests/unit/test_tcod_fov.py index cfbdc33..15f7c54 100644 --- a/tests/unit/test_tcod_fov.py +++ b/tests/unit/test_tcod_fov.py @@ -6,7 +6,7 @@ import sys try: print("1. Creating scene and grid...") - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") grid = mcrfpy.Grid(grid_x=5, grid_y=5, texture=None, pos=(0, 0), size=(80, 80)) print(" Grid created") diff --git a/tests/unit/test_tcod_minimal.py b/tests/unit/test_tcod_minimal.py index af1e4ef..95e9319 100644 --- a/tests/unit/test_tcod_minimal.py +++ b/tests/unit/test_tcod_minimal.py @@ -8,7 +8,7 @@ try: print("1. Module loaded") print("2. Creating scene...") - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") print(" Scene created") print("3. Creating grid with explicit parameters...") diff --git a/tests/unit/test_tcod_pathfinding.py b/tests/unit/test_tcod_pathfinding.py index 0bd0aef..93001a9 100644 --- a/tests/unit/test_tcod_pathfinding.py +++ b/tests/unit/test_tcod_pathfinding.py @@ -6,7 +6,7 @@ import sys try: print("1. Creating scene and grid...") - mcrfpy.createScene("test") + test = mcrfpy.Scene("test") grid = mcrfpy.Grid(grid_x=7, grid_y=7, texture=None, pos=(0, 0), size=(112, 112)) print(" Grid created") diff --git a/tests/unit/test_text_input.py b/tests/unit/test_text_input.py index bc39a7f..007bdc4 100644 --- a/tests/unit/test_text_input.py +++ b/tests/unit/test_text_input.py @@ -14,8 +14,8 @@ from text_input_widget import FocusManager, TextInput def create_demo(): """Create demo scene with text inputs""" # Create scene - mcrfpy.createScene("text_demo") - scene = mcrfpy.sceneUI("text_demo") + text_demo = mcrfpy.Scene("text_demo") + scene = text_demo.children # Background bg = mcrfpy.Frame(pos=(0, 0), size=(800, 600)) @@ -86,8 +86,8 @@ def create_demo(): print(f" Field {i+1}: '{inp.get_text()}'") sys.exit(0) - mcrfpy.keypressScene("text_demo", handle_keys) - mcrfpy.setScene("text_demo") + text_demo.on_key = "text_demo", handle_keys + text_demo.activate() # Run demo test def run_test(timer_name): diff --git a/tests/unit/test_timer_callback.py b/tests/unit/test_timer_callback.py index 7b131a5..24f71f6 100644 --- a/tests/unit/test_timer_callback.py +++ b/tests/unit/test_timer_callback.py @@ -23,8 +23,8 @@ def new_style_callback(arg1, arg2=None): sys.exit(0) # Set up the scene -mcrfpy.createScene("test_scene") -mcrfpy.setScene("test_scene") +test_scene = mcrfpy.Scene("test_scene") +test_scene.activate() print("Testing old style timer with setTimer...") mcrfpy.setTimer("old_timer", old_style_callback, 100) diff --git a/tests/unit/test_timer_legacy.py b/tests/unit/test_timer_legacy.py index 6dbed87..f1a7863 100644 --- a/tests/unit/test_timer_legacy.py +++ b/tests/unit/test_timer_legacy.py @@ -17,8 +17,8 @@ def timer_callback(runtime): sys.exit(0) # Set up the scene -mcrfpy.createScene("test_scene") -mcrfpy.setScene("test_scene") +test_scene = mcrfpy.Scene("test_scene") +test_scene.activate() # Create a timer the old way mcrfpy.setTimer("test_timer", timer_callback, 100) diff --git a/tests/unit/test_timer_object.py b/tests/unit/test_timer_object.py index 96d1e0c..a9ab7b0 100644 --- a/tests/unit/test_timer_object.py +++ b/tests/unit/test_timer_object.py @@ -132,8 +132,8 @@ def run_tests(runtime): mcrfpy.setTimer("final_check", final_check, 2000) # Create a minimal scene -mcrfpy.createScene("timer_test") -mcrfpy.setScene("timer_test") +timer_test = mcrfpy.Scene("timer_test") +timer_test.activate() # Start tests after game loop begins mcrfpy.setTimer("run_tests", run_tests, 100) diff --git a/tests/unit/test_timer_once.py b/tests/unit/test_timer_once.py index 84d48fd..8e7e4fd 100644 --- a/tests/unit/test_timer_once.py +++ b/tests/unit/test_timer_once.py @@ -31,8 +31,8 @@ def check_results(runtime): sys.exit(1) # Set up the scene -mcrfpy.createScene("test_scene") -mcrfpy.setScene("test_scene") +test_scene = mcrfpy.Scene("test_scene") +test_scene.activate() # Create timers print("Creating once timer with once=True...") diff --git a/tests/unit/test_uiarc.py b/tests/unit/test_uiarc.py index 40613df..a308202 100644 --- a/tests/unit/test_uiarc.py +++ b/tests/unit/test_uiarc.py @@ -18,7 +18,7 @@ def run_test(runtime): mcrfpy.delTimer("test") # Get the scene UI - ui = mcrfpy.sceneUI("test") + ui = test.children # Test 1: Create arcs with different parameters print("Test 1: Creating arcs...") @@ -130,8 +130,8 @@ def run_test(runtime): mcrfpy.setTimer("screenshot", take_screenshot, 50) # Create a test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 50) diff --git a/tests/unit/test_uicaption_visual.py b/tests/unit/test_uicaption_visual.py index a4e3fc5..6f0946c 100644 --- a/tests/unit/test_uicaption_visual.py +++ b/tests/unit/test_uicaption_visual.py @@ -11,7 +11,7 @@ def run_visual_test(runtime): print("\nRunning visual tests...") # Get our captions - ui = mcrfpy.sceneUI("test") + ui = test.children # Test 1: Make caption2 invisible print("Test 1: Making caption2 invisible") @@ -65,8 +65,8 @@ def main(): print("=== UICaption Visual Test ===\n") # Create test scene - mcrfpy.createScene("test") - mcrfpy.setScene("test") + test = mcrfpy.Scene("test") + test.activate() # Create multiple captions for testing caption1 = mcrfpy.Caption(pos=(50, 50), text="Caption 1: Normal", fill_color=mcrfpy.Color(255, 255, 255)) @@ -76,7 +76,7 @@ def main(): caption5 = mcrfpy.Caption(pos=(50, 250), text="Caption 5: 0% opacity", fill_color=mcrfpy.Color(255, 255, 200)) # Add captions to scene - ui = mcrfpy.sceneUI("test") + ui = test.children ui.append(caption1) ui.append(caption2) ui.append(caption3) diff --git a/tests/unit/test_uicircle.py b/tests/unit/test_uicircle.py index 4481f38..2116fe3 100644 --- a/tests/unit/test_uicircle.py +++ b/tests/unit/test_uicircle.py @@ -18,7 +18,7 @@ def run_test(runtime): mcrfpy.delTimer("test") # Get the scene UI - ui = mcrfpy.sceneUI("test") + ui = test.children # Test 1: Create circles with different parameters print("Test 1: Creating circles...") @@ -121,8 +121,8 @@ def run_test(runtime): mcrfpy.setTimer("screenshot", take_screenshot, 50) # Create a test scene -mcrfpy.createScene("test") -mcrfpy.setScene("test") +test = mcrfpy.Scene("test") +test.activate() # Schedule test to run after game loop starts mcrfpy.setTimer("test", run_test, 50) diff --git a/tests/unit/test_utf8_encoding.py b/tests/unit/test_utf8_encoding.py index 168bbf9..4980a42 100644 --- a/tests/unit/test_utf8_encoding.py +++ b/tests/unit/test_utf8_encoding.py @@ -31,5 +31,5 @@ def test_utf8(runtime): sys.exit(0) # Run test -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") mcrfpy.setTimer("test", test_utf8, 100) \ No newline at end of file diff --git a/tests/unit/test_vector_arithmetic.py b/tests/unit/test_vector_arithmetic.py index 2bfc9b6..5a8390b 100644 --- a/tests/unit/test_vector_arithmetic.py +++ b/tests/unit/test_vector_arithmetic.py @@ -243,5 +243,5 @@ def test_vector_arithmetic(runtime): sys.exit(0 if all_pass else 1) # Run test -mcrfpy.createScene("test") +test = mcrfpy.Scene("test") mcrfpy.setTimer("test", test_vector_arithmetic, 100) \ No newline at end of file diff --git a/tests/unit/test_viewport_scaling.py b/tests/unit/test_viewport_scaling.py index bf07f9c..0576d3c 100644 --- a/tests/unit/test_viewport_scaling.py +++ b/tests/unit/test_viewport_scaling.py @@ -20,7 +20,7 @@ def test_viewport_modes(runtime): print(f"Window resolution: {window.resolution}") # Create test scene with visual elements - scene = mcrfpy.sceneUI("test") + scene = test.children # Create a frame that fills the game resolution to show boundaries game_res = window.game_resolution @@ -188,7 +188,7 @@ def handle_keypress(key, state): return window = Window.get() - scene = mcrfpy.sceneUI("test") + scene = test.children mode_text = None for elem in scene: if hasattr(elem, 'name') and elem.name == "mode_text": @@ -235,9 +235,9 @@ def handle_keypress(key, state): # Main execution print("Creating viewport test scene...") -mcrfpy.createScene("test") -mcrfpy.setScene("test") -mcrfpy.keypressScene(handle_keypress) +test = mcrfpy.Scene("test") +test.activate() +test.on_key = handle_keypress # Schedule the test mcrfpy.setTimer("test_viewport", test_viewport_modes, 100) diff --git a/tests/unit/test_visibility.py b/tests/unit/test_visibility.py index b866078..c735558 100644 --- a/tests/unit/test_visibility.py +++ b/tests/unit/test_visibility.py @@ -14,7 +14,7 @@ print("Knowledge Stubs 1 - Visibility System Test") print("==========================================") # Create scene and grid -mcrfpy.createScene("visibility_test") +visibility_test = mcrfpy.Scene("visibility_test") grid = mcrfpy.Grid(grid_x=20, grid_y=15) grid.fill_color = mcrfpy.Color(20, 20, 30) # Dark background @@ -135,7 +135,7 @@ visible_count = sum(1 for state in entity.gridstate if state.visible) print(f" Visible cells after move: {visible_count}") # Set up UI -ui = mcrfpy.sceneUI("visibility_test") +ui = visibility_test.children ui.append(grid) grid.position = (50, 50) grid.size = (600, 450) # 20*30, 15*30 @@ -156,7 +156,7 @@ legend.fill_color = mcrfpy.Color(150, 150, 150) ui.append(legend) # Set scene -mcrfpy.setScene("visibility_test") +visibility_test.activate() # Set timer to cycle perspectives mcrfpy.setTimer("cycle", visual_test, 2000) # Every 2 seconds diff --git a/tests/unit/test_visual_path.py b/tests/unit/test_visual_path.py index 11a8c71..7c8c133 100644 --- a/tests/unit/test_visual_path.py +++ b/tests/unit/test_visual_path.py @@ -10,7 +10,7 @@ FLOOR_COLOR = mcrfpy.Color(200, 200, 220) PATH_COLOR = mcrfpy.Color(100, 255, 100) # Create scene -mcrfpy.createScene("visual_test") +visual_test = mcrfpy.Scene("visual_test") # Create grid grid = mcrfpy.Grid(grid_x=5, grid_y=5) @@ -64,7 +64,7 @@ if path: print(f" Set ({x},{y}) to green") # Set up UI -ui = mcrfpy.sceneUI("visual_test") +ui = visual_test.children ui.append(grid) grid.position = (50, 50) grid.size = (250, 250) @@ -75,7 +75,7 @@ title.fill_color = mcrfpy.Color(255, 255, 255) ui.append(title) # Set scene -mcrfpy.setScene("visual_test") +visual_test.activate() # Set timer to check rendering mcrfpy.setTimer("check", check_render, 500) diff --git a/tests/unit/ui_Entity_issue73_test.py b/tests/unit/ui_Entity_issue73_test.py index 7f2b3cd..304db18 100644 --- a/tests/unit/ui_Entity_issue73_test.py +++ b/tests/unit/ui_Entity_issue73_test.py @@ -8,9 +8,9 @@ print("Test script starting...") def test_Entity(): """Test Entity class and index() method for collection removal""" # Create test scene with grid - mcrfpy.createScene("entity_test") - mcrfpy.setScene("entity_test") - ui = mcrfpy.sceneUI("entity_test") + entity_test = mcrfpy.Scene("entity_test") + entity_test.activate() + ui = entity_test.children # Create a grid grid = mcrfpy.Grid(10, 10, diff --git a/tests/unit/ui_Frame_test_detailed.py b/tests/unit/ui_Frame_test_detailed.py index 938a5a4..de50c0f 100644 --- a/tests/unit/ui_Frame_test_detailed.py +++ b/tests/unit/ui_Frame_test_detailed.py @@ -8,9 +8,9 @@ def test_issue_38_children(): print("\n=== Testing Issue #38: children argument in Frame constructor ===") # Create test scene - mcrfpy.createScene("issue38_test") - mcrfpy.setScene("issue38_test") - ui = mcrfpy.sceneUI("issue38_test") + issue38_test = mcrfpy.Scene("issue38_test") + issue38_test.activate() + ui = issue38_test.children # Test 1: Try to pass children in constructor print("\nTest 1: Passing children argument to Frame constructor") @@ -54,9 +54,9 @@ def test_issue_42_click_callback(): print("\n\n=== Testing Issue #42: click callback arguments ===") # Create test scene - mcrfpy.createScene("issue42_test") - mcrfpy.setScene("issue42_test") - ui = mcrfpy.sceneUI("issue42_test") + issue42_test = mcrfpy.Scene("issue42_test") + issue42_test.activate() + ui = issue42_test.children # Test 1: Callback with correct signature print("\nTest 1: Click callback with correct signature (x, y, button)") diff --git a/tests/unit/ui_Grid_none_texture_test.py b/tests/unit/ui_Grid_none_texture_test.py index a283cee..668ac7e 100644 --- a/tests/unit/ui_Grid_none_texture_test.py +++ b/tests/unit/ui_Grid_none_texture_test.py @@ -17,7 +17,7 @@ def test_grid_none_texture(runtime): sys.exit(1) # Add to UI - ui = mcrfpy.sceneUI("grid_none_test") + ui = grid_none_test.children ui.append(grid) # Test 2: Verify grid properties @@ -83,11 +83,11 @@ def test_grid_none_texture(runtime): # Set up test scene print("Creating test scene...") -mcrfpy.createScene("grid_none_test") -mcrfpy.setScene("grid_none_test") +grid_none_test = mcrfpy.Scene("grid_none_test") +grid_none_test.activate() # Add a background frame so we can see the grid -ui = mcrfpy.sceneUI("grid_none_test") +ui = grid_none_test.children background = mcrfpy.Frame(pos=(0, 0), size=(800, 600), fill_color=mcrfpy.Color(200, 200, 200), outline_color=mcrfpy.Color(0, 0, 0), diff --git a/tests/unit/ui_Grid_null_texture_test.py b/tests/unit/ui_Grid_null_texture_test.py index fdac956..2ec0cae 100644 --- a/tests/unit/ui_Grid_null_texture_test.py +++ b/tests/unit/ui_Grid_null_texture_test.py @@ -8,9 +8,9 @@ def test_grid_null_texture(): print("=== Testing Grid with null texture ===") # Create test scene - mcrfpy.createScene("grid_null_test") - mcrfpy.setScene("grid_null_test") - ui = mcrfpy.sceneUI("grid_null_test") + grid_null_test = mcrfpy.Scene("grid_null_test") + grid_null_test.activate() + ui = grid_null_test.children # Test 1: Try with None try: diff --git a/tests/unit/ui_Grid_test_no_grid.py b/tests/unit/ui_Grid_test_no_grid.py index 836543e..ac485e9 100644 --- a/tests/unit/ui_Grid_test_no_grid.py +++ b/tests/unit/ui_Grid_test_no_grid.py @@ -6,11 +6,11 @@ print("Starting test...") # Create test scene print("[DEBUG] Creating scene...") -mcrfpy.createScene("grid_test") +grid_test = mcrfpy.Scene("grid_test") print("[DEBUG] Setting scene...") -mcrfpy.setScene("grid_test") +grid_test.activate() print("[DEBUG] Getting UI...") -ui = mcrfpy.sceneUI("grid_test") +ui = grid_test.children print("[DEBUG] UI retrieved") # Test texture creation diff --git a/tests/unit/ui_Sprite_issue19_test.py b/tests/unit/ui_Sprite_issue19_test.py index 65539e9..b8cefe5 100644 --- a/tests/unit/ui_Sprite_issue19_test.py +++ b/tests/unit/ui_Sprite_issue19_test.py @@ -5,9 +5,9 @@ import mcrfpy print("Testing Sprite texture methods (Issue #19)...") # Create test scene -mcrfpy.createScene("sprite_texture_test") -mcrfpy.setScene("sprite_texture_test") -ui = mcrfpy.sceneUI("sprite_texture_test") +sprite_texture_test = mcrfpy.Scene("sprite_texture_test") +sprite_texture_test.activate() +ui = sprite_texture_test.children # Create sprites # Based on sprite2 syntax: Sprite(x, y, texture, sprite_index, scale) diff --git a/tests/unit/ui_UICollection_issue69_test.py b/tests/unit/ui_UICollection_issue69_test.py index 44af8d2..86fd3ef 100644 --- a/tests/unit/ui_UICollection_issue69_test.py +++ b/tests/unit/ui_UICollection_issue69_test.py @@ -6,9 +6,9 @@ from datetime import datetime def test_UICollection(): """Test UICollection sequence protocol compliance""" # Create test scene - mcrfpy.createScene("collection_test") - mcrfpy.setScene("collection_test") - ui = mcrfpy.sceneUI("collection_test") + collection_test = mcrfpy.Scene("collection_test") + collection_test.activate() + ui = collection_test.children # Add various UI elements frame = mcrfpy.Frame(pos=(10, 10), size=(100, 100)) diff --git a/tests/unit/validate_screenshot_test.py b/tests/unit/validate_screenshot_test.py index 7e1a068..96c8652 100644 --- a/tests/unit/validate_screenshot_test.py +++ b/tests/unit/validate_screenshot_test.py @@ -10,9 +10,9 @@ def test_screenshot_validation(): print("=== Screenshot Validation Test ===\n") # Create a scene with bright, visible content - mcrfpy.createScene("screenshot_validation") - mcrfpy.setScene("screenshot_validation") - ui = mcrfpy.sceneUI("screenshot_validation") + screenshot_validation = mcrfpy.Scene("screenshot_validation") + screenshot_validation.activate() + ui = screenshot_validation.children # Create multiple colorful elements to ensure visibility print("Creating UI elements...") diff --git a/tests/unit/working_timer_test.py b/tests/unit/working_timer_test.py index a9d96c5..bddeff4 100644 --- a/tests/unit/working_timer_test.py +++ b/tests/unit/working_timer_test.py @@ -6,9 +6,9 @@ from mcrfpy import automation print("Setting up timer test...") # Create a scene -mcrfpy.createScene("timer_works") -mcrfpy.setScene("timer_works") -ui = mcrfpy.sceneUI("timer_works") +timer_works = mcrfpy.Scene("timer_works") +timer_works.activate() +ui = timer_works.children # Add visible content frame = mcrfpy.Frame(pos=(100, 100), size=(300, 200), diff --git a/tests/vllm_demo/0_basic_vllm_demo.py b/tests/vllm_demo/0_basic_vllm_demo.py index bf37fa4..1198dda 100644 --- a/tests/vllm_demo/0_basic_vllm_demo.py +++ b/tests/vllm_demo/0_basic_vllm_demo.py @@ -72,9 +72,9 @@ def setup_scene(): print("Setting up scene...") # Create and set scene - mcrfpy.createScene("vllm_demo") - mcrfpy.setScene("vllm_demo") - ui = mcrfpy.sceneUI("vllm_demo") + vllm_demo = mcrfpy.Scene("vllm_demo") + vllm_demo.activate() + ui = vllm_demo.children # Load the game texture (16x16 tiles from Crypt of Sokoban) texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16) diff --git a/tests/vllm_demo/1_multi_agent_demo.py b/tests/vllm_demo/1_multi_agent_demo.py index b69bccb..d6234b3 100644 --- a/tests/vllm_demo/1_multi_agent_demo.py +++ b/tests/vllm_demo/1_multi_agent_demo.py @@ -100,9 +100,9 @@ def setup_scene(): print("Setting up multi-agent scene...") # Create and set scene - mcrfpy.createScene("multi_agent_demo") - mcrfpy.setScene("multi_agent_demo") - ui = mcrfpy.sceneUI("multi_agent_demo") + multi_agent_demo = mcrfpy.Scene("multi_agent_demo") + multi_agent_demo.activate() + ui = multi_agent_demo.children # Load the game texture texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16) diff --git a/tests/vllm_demo/2_integrated_demo.py b/tests/vllm_demo/2_integrated_demo.py index f499079..38d25b8 100644 --- a/tests/vllm_demo/2_integrated_demo.py +++ b/tests/vllm_demo/2_integrated_demo.py @@ -126,9 +126,9 @@ def setup_scene_from_world(world: WorldGraph): Carves out rooms and places doors based on WorldGraph data. """ - mcrfpy.createScene("integrated_demo") - mcrfpy.setScene("integrated_demo") - ui = mcrfpy.sceneUI("integrated_demo") + integrated_demo = mcrfpy.Scene("integrated_demo") + integrated_demo.activate() + ui = integrated_demo.children texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16) diff --git a/tests/vllm_demo/3_multi_turn_demo.py b/tests/vllm_demo/3_multi_turn_demo.py index 3e830c3..6f96f81 100644 --- a/tests/vllm_demo/3_multi_turn_demo.py +++ b/tests/vllm_demo/3_multi_turn_demo.py @@ -131,9 +131,9 @@ What do you do? Brief reasoning (1-2 sentences), then Action: """ def setup_scene(world: WorldGraph): """Create McRogueFace scene from WorldGraph.""" - mcrfpy.createScene("multi_turn") - mcrfpy.setScene("multi_turn") - ui = mcrfpy.sceneUI("multi_turn") + multi_turn = mcrfpy.Scene("multi_turn") + multi_turn.activate() + ui = multi_turn.children texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16) diff --git a/tests/vllm_demo/4_enhanced_action_demo.py b/tests/vllm_demo/4_enhanced_action_demo.py index 2986733..ce17e1e 100644 --- a/tests/vllm_demo/4_enhanced_action_demo.py +++ b/tests/vllm_demo/4_enhanced_action_demo.py @@ -180,9 +180,9 @@ Always end your final response with: Action: """ def setup_scene(world: WorldGraph): """Create McRogueFace scene from WorldGraph.""" - mcrfpy.createScene("enhanced_demo") - mcrfpy.setScene("enhanced_demo") - ui = mcrfpy.sceneUI("enhanced_demo") + enhanced_demo = mcrfpy.Scene("enhanced_demo") + enhanced_demo.activate() + ui = enhanced_demo.children texture = mcrfpy.Texture("assets/kenney_TD_MR_IP.png", 16, 16)