-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GH-91] Move ship input rendering to a component
- Loading branch information
Showing
7 changed files
with
107 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
// TODO: Migrate to IIFE once PHP 5 support is removed | ||
call_user_func(function () { | ||
global $_EnginePath; | ||
|
||
$includePath = $_EnginePath . 'modules/attackSimulator/'; | ||
|
||
include($includePath . './components/ShipInput/ShipInput.component.php'); | ||
|
||
}); | ||
|
||
?> |
47 changes: 47 additions & 0 deletions
47
modules/attackSimulator/components/ShipInput/ShipInput.component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\AttackSimulator\Components\ShipInput; | ||
|
||
/** | ||
* @param array $props | ||
* @param number $props['slotIdx'] | ||
* @param number $props['elementId'] | ||
* @param enum ("attacker" | "defender") $props['columnType'] | ||
* @param number $props['initialValue'] | ||
*/ | ||
function render($props) { | ||
global $_Lang; | ||
|
||
$slotIdx = $props['slotIdx']; | ||
$elementId = $props['elementId']; | ||
|
||
$inputNamePrefix = ( | ||
$props['columnType'] === 'attacker' ? | ||
'atk_ships' : | ||
'def_ships' | ||
); | ||
|
||
$templateBodyProps = [ | ||
'prop_tabIndex' => ( | ||
$props['columnType'] === 'attacker' ? | ||
'1' : | ||
'2' | ||
), | ||
'prop_inputName' => "{$inputNamePrefix}[{$slotIdx}][{$elementId}]", | ||
'prop_initialValue' => $props['initialValue'], | ||
'lang_Button_Min' => $_Lang['Button_Min'], | ||
'lang_Button_Max' => $_Lang['Button_Max'], | ||
]; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$componentHTML = parsetemplate( | ||
$localTemplateLoader('body'), | ||
$templateBodyProps | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<input | ||
type="text" | ||
tabindex="{prop_tabIndex}" | ||
name="{prop_inputName}" | ||
value="{prop_initialValue}" | ||
autocomplete="off" | ||
class="pad2 fl" | ||
/> | ||
<span class="fr"> | ||
(<span class="clnOne point">{lang_Button_Min}</span> / <span class="maxOne point">{lang_Button_Max}</span>) | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters