MAPG-203 implement game mode selection UI
This commit is contained in:
parent
24a10c534e
commit
563f900423
@ -73,4 +73,40 @@
|
||||
window.onresize = function () {
|
||||
Maps.calculateDescriptionDivHeights();
|
||||
};
|
||||
|
||||
document.getElementById('multiForm').onsubmit = function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var roomId = this.elements.roomId.value;
|
||||
if (roomId.length !== 6) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = '/multiGame/' + this.elements.roomId.value;
|
||||
};
|
||||
|
||||
document.getElementById('multiButton').onclick = function () {
|
||||
MapGuesser.showModal('multi');
|
||||
document.getElementById('createNewRoomButton').href = '/multiGame/new/' + this.dataset.mapId;
|
||||
document.getElementById('multiForm').elements.roomId.select();
|
||||
}
|
||||
|
||||
document.getElementById('closePlayModeButton').onclick = function () {
|
||||
MapGuesser.hideModal();
|
||||
};
|
||||
|
||||
document.getElementById('closeMultiButton').onclick = function () {
|
||||
MapGuesser.hideModal();
|
||||
};
|
||||
|
||||
var buttons = document.getElementById('mapContainer').getElementsByClassName('playButton');
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
var button = buttons[i];
|
||||
|
||||
button.onclick = function () {
|
||||
MapGuesser.showModal('playMode');
|
||||
document.getElementById('singleButton').href = '/game/' + this.dataset.mapId;
|
||||
document.getElementById('multiButton').dataset.mapId = this.dataset.mapId;
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
@ -5,6 +5,32 @@ TODO: condition!
|
||||
|
||||
@extends(templates/layout_normal)
|
||||
|
||||
@section(pagemodal)
|
||||
<div id="playMode" class="modal">
|
||||
<h2>Play map</h2>
|
||||
<a id="singleButton" class="button fullWidth marginTop" href="" title="Single player">Single player</a>
|
||||
<p class="bold center marginTop marginBottom">OR</p>
|
||||
<button id="multiButton" class="fullWidth green" data-map-id="">Multiplayer (beta)</button>
|
||||
<div class="right">
|
||||
<button id="closePlayModeButton" class="gray marginTop" type="button">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="multi" class="modal">
|
||||
<h2>Multiplayer (beta)</h2>
|
||||
<form id="multiForm" class="marginTop" data-no-submit="true">
|
||||
<a id="createNewRoomButton" class="button fullWidth green" href="" title="Create new room">Create new room</a>
|
||||
<p class="bold center marginTop marginBottom">OR</p>
|
||||
<div class="inputWithButton">
|
||||
<input type="text" name="roomId" placeholder="Room to connect" required minlength="6" maxlength="6"><!--
|
||||
--><button id="authenticateWithGoogleButton" type="submit">Connect</button>
|
||||
</div>
|
||||
<div class="right">
|
||||
<button id="closeMultiButton" class="gray marginTop" type="button">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section(main)
|
||||
<div id="mapContainer">
|
||||
<?php foreach ($maps as $map): ?>
|
||||
@ -35,15 +61,15 @@ TODO: condition!
|
||||
<p class="small center"><?= $map['description'] ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($isAdmin): ?>
|
||||
<div class="buttonContainer">
|
||||
<a class="button fullWidth noRightRadius" href="/game/<?= $map['id']; ?>" title="Play map '<?= $map['name'] ?>'">Play this map</a>
|
||||
<div class="buttonContainer">
|
||||
<?php if ($isAdmin): ?>
|
||||
<button class="button fullWidth noRightRadius playButton" data-map-id="<?= $map['id'] ?>" data-map-name="<?= htmlspecialchars($map['name']) ?>" title="Play map '<?= $map['name'] ?>'">Play this map</button>
|
||||
<a class="button yellow fullWidth noLeftRadius noRightRadius" href="/admin/mapEditor/<?= $map['id']; ?>" title="Edit map '<?= $map['name'] ?>'">Edit</a>
|
||||
<button class="button red fullWidth noLeftRadius deleteButton" data-map-id="<?= $map['id'] ?>" data-map-name="<?= htmlspecialchars($map['name']) ?>" title="Delete map '<?= $map['name'] ?>'">Delete</button>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<a class="button fullWidth" href="/game/<?= $map['id']; ?>" title="Play map '<?= $map['name'] ?>'">Play this map</a>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<button class="button fullWidth playButton" data-map-id="<?= $map['id'] ?>" data-map-name="<?= htmlspecialchars($map['name']) ?>" title="Play map '<?= $map['name'] ?>'">Play this map</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($isAdmin): ?>
|
||||
|
Loading…
Reference in New Issue
Block a user