(gui, controller)
| 2514 | } |
| 2515 | |
| 2516 | function recallSavedValue(gui, controller) { |
| 2517 | |
| 2518 | // Find the topmost GUI, that's where remembered objects live. |
| 2519 | var root = gui.getRoot(); |
| 2520 | |
| 2521 | // Does the object we're controlling match anything we've been told to |
| 2522 | // remember? |
| 2523 | var matched_index = root.__rememberedObjects.indexOf(controller.object); |
| 2524 | |
| 2525 | // Why yes, it does! |
| 2526 | if (matched_index != -1) { |
| 2527 | |
| 2528 | // Let me fetch a map of controllers for thcommon.isObject. |
| 2529 | var controller_map = |
| 2530 | root.__rememberedObjectIndecesToControllers[matched_index]; |
| 2531 | |
| 2532 | // Ohp, I believe this is the first controller we've created for this |
| 2533 | // object. Lets make the map fresh. |
| 2534 | if (controller_map === undefined) { |
| 2535 | controller_map = {}; |
| 2536 | root.__rememberedObjectIndecesToControllers[matched_index] = |
| 2537 | controller_map; |
| 2538 | } |
| 2539 | |
| 2540 | // Keep track of this controller |
| 2541 | controller_map[controller.property] = controller; |
| 2542 | |
| 2543 | // Okay, now have we saved any values for this controller? |
| 2544 | if (root.load && root.load.remembered) { |
| 2545 | |
| 2546 | var preset_map = root.load.remembered; |
| 2547 | |
| 2548 | // Which preset are we trying to load? |
| 2549 | var preset; |
| 2550 | |
| 2551 | if (preset_map[gui.preset]) { |
| 2552 | |
| 2553 | preset = preset_map[gui.preset]; |
| 2554 | |
| 2555 | } else if (preset_map[DEFAULT_DEFAULT_PRESET_NAME]) { |
| 2556 | |
| 2557 | // Uhh, you can have the default instead? |
| 2558 | preset = preset_map[DEFAULT_DEFAULT_PRESET_NAME]; |
| 2559 | |
| 2560 | } else { |
| 2561 | |
| 2562 | // Nada. |
| 2563 | |
| 2564 | return; |
| 2565 | |
| 2566 | } |
| 2567 | |
| 2568 | |
| 2569 | // Did the loaded object remember thcommon.isObject? |
| 2570 | if (preset[matched_index] && |
| 2571 | |
| 2572 | // Did we remember this particular property? |
| 2573 | preset[matched_index][controller.property] !== undefined) { |
no outgoing calls
no test coverage detected