Skip to content

Commit

Permalink
[1.6.11] expansion block select modal update
Browse files Browse the repository at this point in the history
  • Loading branch information
extracold1209 committed Aug 22, 2018
1 parent 032b1a0 commit 5a6113c
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/entry_offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ipcMain,
webContents,
dialog,
net,
net,
} from 'electron';
import path from 'path';
import fs from 'fs';
Expand Down
1 change: 1 addition & 0 deletions src/renderer/entry_offline.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<script type="text/javascript" src="./src/picture_import.js"></script>
<script type="text/javascript" src="./src/sprite.js"></script>
<script type="text/javascript" src="./src/header.js"></script>
<script type="text/javascript" src="./src/expansion_block.js"></script>
<script type="text/javascript" src="./src/sound.js"></script>
<script type="text/javascript" src="./src/initialize.js"></script>
<div class="entryUploaderWindow">
Expand Down
156 changes: 156 additions & 0 deletions src/renderer/src/expansion_block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@

angular.module('common').controller('ExpansionBlockController', ['$scope', '$uibModalInstance', '$routeParams', '$http', 'parent',
function ($scope, $uibModalInstance, $routeParams, $http, parent) {
$scope.parent = parent;

$scope.systemBlocks = [];
$scope.selectedSystem = [];
$scope.selectedBlock = { description : "" };

$scope.main_menu = "test";
$scope.menu = "";
$scope.cursor = 0;

$scope.initList = function() {
var expansionBlocks = _.uniq(_.values(Entry.EXPANSION_BLOCK_LIST));
expansionBlocks = _.sortBy(expansionBlocks, function (item) {
var result = '';
if(item.title) {
item.nameByLang = item.title[Lang.type];
result = item.title.ko.toLowerCase();
}
return result;
});

$scope.systemBlocks = expansionBlocks;
}

$scope.init = function() {
$routeParams.type = 'default';
$routeParams.main = 'test';
$scope.collapse(1);
$scope.initList();

};

// 현재 선택한 탭
$scope.currentTab = 'system'; //for modal(sprite,upload,paint,character,text,etc)

$scope.selectedUpload = [];
$scope.currentIndex = 0;

$scope.applySystem = function(block) {
$scope.selectedSystem = [];
$scope.selectedSystem.push(block);
$scope.selectedBlock = block;

$uibModalInstance.close({
target: $scope.currentTab,
data: $scope.currentSelected()
});
};

function _selectedMapFunc(datum) {
var ret = _.findWhere($scope.selectedSystem || [], {
_id: datum.name,
});
if (ret) {
datum.selected = 'boxOuter selected';
} else {
datum.selected = 'boxOuter';
}
return datum;
}

// 선택
$scope.selectSystem = function(block) {
var blockId = block.name;
var idx = _.findIndex($scope.selectedSystem, function(item) {
return blockId === item.name;
});

var selector = '#'+ blockId + '.boxOuter';

if (~idx) {
$scope.selectedSystem.splice(idx, 1);
jQuery(selector).attr('class', 'boxOuter');
$scope.moveContainer('right');
} else {
$scope.selectedSystem.push(block);
$scope.selectedBlock = block;
// 스프라이트 다중 선택.
jQuery(selector).attr('class', 'boxOuter selected');
$scope.moveContainer('left');
}
};

$scope.moveContainer = function (direction) {
var mover = jQuery('.modal_selected_container_moving').eq(0);
var blocks = $scope.selectedSystem;

if (direction == 'left' && (blocks.length-1 < 5 || $scope.cursor == blocks.length-1)) return;
if (direction == 'right' && ($scope.cursor == 0 || blocks.length < 5 && $scope.cursor > blocks.length)) return;

var marginL = parseInt(mover.css("margin-left"));
if (direction == 'left') {
mover.css("margin-left", (marginL - 106) + 'px');
$scope.cursor = $scope.cursor + 1;
} else {
mover.css("margin-left", (marginL + 106) + 'px');
$scope.cursor = $scope.cursor - 1;
}
}

$scope.currentSelected = function() {
if ($scope.currentTab === 'system') {
return $scope.selectedSystem;
} else if ($scope.currentTab === 'upload') {
return $scope.selectedUpload;
} else if ($scope.currentTab === 'textBox') {
return 'textBox';
} else {
return null;
}
};

$scope.addExpansionBlock = function() {
$uibModalInstance.close({
target: 'new'
});
};

$scope.collapse = function(dest) {
for (var i=1; i<10; i++)
$scope['isCollapsed' + i] = true;

if (dest > 0) {
$scope['isCollapsed' + dest] = false;
$('#searchWord').val('');
}
};

// 적용
$scope.ok = function () {
if (!$scope.currentSelected()) {
entrylms.alert(Lang.Workspace.select_sprite);
} else {
$uibModalInstance.close({
target: $scope.currentTab,
data: $scope.currentSelected()
});
}
};

// 취소
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};

$scope.dict = {
'WORKSPACE_LOAD_EXPANSION_BLOCK': Lang.Workspace.load_exapnsion_block,
'WORKSPACE_SELECT_EXPANSION_BLOCK': Lang.Workspace.select_expansion_block,
'BUTTONS_APPLY': Lang.Buttons.apply,
'BUTTONS_CANCEL': Lang.Buttons.cancel,
'WEATHER_DESC': Lang.Msgs.expansion_weather_description
}
}]);
26 changes: 26 additions & 0 deletions src/renderer/src/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ angular
'saveLocalStorageProject',
saveLocalStorageProject
);
Entry.addEventListener(
'openExpansionBlockManager',
$scope.openExpansionBlockManager
);
Entry.addEventListener('saveBlockImages', saveBlockImages);
Entry.addEventListener('removeObject', removeObject);
Entry.addEventListener('removePicture', removePicture);
Expand Down Expand Up @@ -412,6 +416,28 @@ angular
});
};

$scope.openExpansionBlockManager = function() {
const modalInstance = $modal.open({
templateUrl: './views/modal/expansion_block.html',
controller: 'ExpansionBlockController',
backdrop: false,
keyboard: false,
resolve: {
parent: function() {
return "workspace";
}
}
});

modalInstance.result.then(function (selectedItems) {
selectedItems.data.forEach(function(item) {
item.id = Entry.generateHash();
Entry.playground.addExpansionBlock(item, true, true);
});

});
};

$scope.setOfflineHW = function() {
Entry.HW.prototype.downloadConnector = function() {
remote.getGlobal('sharedObject').roomId = [
Expand Down
49 changes: 49 additions & 0 deletions src/renderer/views/modal/expansion_block.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

<div data-ng-init="init()">
<div class="modal-content" ng-class="{'modal-lecture': parent == 'lecture', 'modal-workspace': parent == 'workspace'}">
<div class="modal-header">
<button type="button" class="close" ng-click="cancel()">
<img src='images/close_modal_workspace.png'/>
</button>
<h4 class="modal-title">{{::dict.WORKSPACE_LOAD_EXPANSION_BLOCK}}</h4>
</div>
<div class="modal-body" style="margin:0">
<div class="row">
<div class="col-md-9 tab-right" style="width:100%; padding-left:0; padding-right: 0">
<div class="wrap wrap_sprite">
<div class="box" data-ng-repeat="block in systemBlocks">
<div id="{{::block.name}}" class="boxOuter {{::block.selected}}" data-ng-click="selectSystem(block)" data-ng-dblclick="applySystem(block)">
<div class="boxInner" style="background-image: url('bower_components/entryjs/images/hardware/{{::block.imageName}}');"></div>
<img class="overlay" src="images/check_inside_new.png"/>
</div>
<div class="titleBox">{{block.nameByLang}}</div>
</div>
</div>
</div>
</div>

<div class="modal_choosen" style="width: 100%; margin-left: 0">
<div class='modal_selected_arrow modal_selected_left_arrow' ng-click='moveContainer("right")'></div>
<div class='modal_selected_arrow modal_selected_right_arrow' ng-click='moveContainer("left")'></div>
<div class="modal_selected_container">
<div class="modal_selected_container_moving">
<div class="box" data-ng-repeat="block in selectedSystem" ng-if="currentTab == 'system'">
<div id="{{::block.name}}" class="boxOuter {{::block.selected}} boxOuterChoosen">
<img class="modal_choosen_cancel" src="images/modal_choosen_cancel.png" data-ng-click="selectSystem(block)"/>
<div class="boxInner" style="background-image: url('bower_components/entryjs/images/hardware/{{::block.imageName}}');"></div>
</div>
<div class="titleBox titleBoxChoosen">{{::block.nameByLang}}</div>
</div>
</div>
</div>
</div>
<div class="modalFilter" ng-if="selectedSystem.length > 0" style="width:100%; margin-left: 0;font-size: 14px; color: #565656; padding-right: 12px; text-align: right">
{{::selectedBlock.description}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn_confirm_modal" data-ng-click="ok()">{{::dict.BUTTONS_APPLY}} ({{currentSelected().length}})</button>
<button type="button" class="btn btn_cancel_modal" data-ng-click="cancel()">{{::dict.BUTTONS_CANCEL}}</button>
</div>
</div>
</div>

0 comments on commit 5a6113c

Please sign in to comment.