Skip to content

Commit

Permalink
fix: Buttons in level editor popup (#1539)
Browse files Browse the repository at this point in the history
* fix: Buttons in level editor popup

* Remove codecov comment

* Disable comments
  • Loading branch information
faucomte97 authored Nov 28, 2023
1 parent 31dde05 commit 4ceb8a7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 42 deletions.
11 changes: 2 additions & 9 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ coverage:
patch:
default:
target: 90%

comment:
layout: "reach, diff, flags, files"
behavior: new
require_changes: false
require_base: no
require_head: yes
branches:
- "!master"

comment: false

ignore:
- "game/tests/*.py"
Expand Down
6 changes: 6 additions & 0 deletions game/static/game/css/game_screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ button > svg {
padding-right: 10px;
}

.navigation_button_portal_secondary.long_button span {
text-align: left;
margin: 0;
width: 100%;
}

.long_button img + span {
line-height: 30px;
margin-left: 2px;
Expand Down
27 changes: 9 additions & 18 deletions game/static/game/js/drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,11 +1102,20 @@ ocargo.Drawing.startPopup = function (
tryAgainButton.removeClass().addClass("navigation_button_portal long_button rapid-router-welcome")
buttonDiv.append(tryAgainButton)

let editButton = $("#edit_button")
editButton.removeClass().addClass("navigation_button_portal long_button rapid-router-welcome")
buttonDiv.append(editButton)

let nextLevelButton = $("#next_level_button")
nextLevelButton.removeClass().addClass("navigation_button_portal_secondary long_button rapid-router-welcome button--icon")
nextLevelButton.append(icons[2])
buttonDiv.append(nextLevelButton)

let playButton = $("#play_button")
playButton.removeClass().addClass("navigation_button_portal_secondary long_button rapid-router-welcome button--icon")
playButton.append(icons[2])
buttonDiv.append(playButton)

$("#modal-buttons").html(buttonDiv)
} else {
$('#modal-buttons').html(
Expand Down Expand Up @@ -1140,24 +1149,6 @@ ocargo.Drawing.startYesNoPopup = function (
$('#modal-noBtn').click(noFunction)
}

// This provides a pop-up with 2 options
ocargo.Drawing.startOptionsPopup = function (
title,
subtitle,
message,
optionAFunction,
optionBFunction,
optionAText,
optionBText,
mascot
) {
let buttonHtml =
'<button id="modal-optionABtn" class="navigation_button long_button">' + optionAText + '</button> <button id="modal-optionBBtn" class="navigation_button long_button">' + optionBText + '</button>'
ocargo.Drawing.startPopup(title, subtitle, message, mascot, buttonHtml)
$('#modal-optionABtn').click(optionAFunction)
$('#modal-optionBBtn').click(optionBFunction)
}

// This is the function that starts the pop-up when there is no internet connection while playing the game
ocargo.Drawing.startInternetDownPopup = function () {
ocargo.Drawing.startPopup(
Expand Down
21 changes: 6 additions & 15 deletions game/static/game/js/level_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,6 @@ ocargo.LevelEditor = function(levelId) {
/******************/

$(function() {
var editor = new ocargo.LevelEditor(LEVEL);
var subtitle = interpolate(
gettext('Click %(help_icon)s%(help_label)s for clues on getting started.'), {
help_icon: ocargo.jsElements.image(ocargo.Drawing.imageDir + 'icons/help.svg', 'popupHelp'),
Expand All @@ -2738,24 +2737,16 @@ $(function() {
if (LEVEL === null){
ocargo.Drawing.startPopup(gettext('Welcome to the Level editor!'), subtitle, '');
} else {
var optionAFunc = function(){
$(".ocargo-modal").hide();
$(".modal-overlay").hide();
};

var optionBFunc = function(){
window.location.replace("/rapidrouter/custom/"+LEVEL+"/");
};
let buttons = '';
buttons += ocargo.button.dismissButtonHtml("edit_button", "Edit");
buttons += ocargo.button.redirectButtonHtml("play_button", Urls.levels() + "custom/" + LEVEL,"Play");

ocargo.Drawing.startOptionsPopup(
ocargo.Drawing.startPopup(
gettext('Welcome back!'),
gettext('Would you like to edit or play with your design?'),
'',
optionAFunc,
optionBFunc,
"Edit",
"Play",
''
false,
buttons,
);
}

Expand Down

0 comments on commit 4ceb8a7

Please sign in to comment.