diff --git a/twe/install.php b/twe/install.php index 7de3e56a..b9c41885 100644 --- a/twe/install.php +++ b/twe/install.php @@ -94,13 +94,7 @@ if(Session::getUserGrade(true) < 5){
-
@@ -183,9 +177,9 @@ if(Session::getUserGrade(true) < 5){ 설정값 - 일자180년 1월 + 시작 연도180년 NPC 수 - 국가 수 + 국가 diff --git a/twe/j_load_scenarios.php b/twe/j_load_scenarios.php index 836da0bd..1b937515 100644 --- a/twe/j_load_scenarios.php +++ b/twe/j_load_scenarios.php @@ -2,8 +2,8 @@ namespace sammo; require "lib.php"; - -if(Session::getUserGrade() < 5){ +$session = Session::Instance()->setReadOnly(); +if($session->userGrade < 5){ Json::die([ 'result'=>false, 'reason'=>'관리자가 아닙니다.' @@ -21,7 +21,13 @@ if ($scenarioIdx !== null) { ]); } + +$scenarios = []; +foreach(Scenario::getAllScenarios() as $scenario){ + $scenarios[$scenario->getScenarioIdx()] = $scenario->getScenarioBrief(); +} + Json::die([ - 'result'=>false, - 'reason'=>'NYI' + 'result'=>true, + 'scenario'=>$scenarios ]); \ No newline at end of file diff --git a/twe/js/install.js b/twe/js/install.js index fa092207..c192bb14 100644 --- a/twe/js/install.js +++ b/twe/js/install.js @@ -19,16 +19,91 @@ function loadScenarioPreview(scenarioIdx){ } */ + + function loadScenarios(){ $.ajax({ method:'post', url:'j_load_scenarios.php', dataType:'json' }).then(function(result){ + if(!result.result){ + var deferred = $.Deferred(); + deferred.reject('fail'); + return deferred.promise(); + } + + var list = {}; + + + $.each(result.scenario, function(idx, value){ + var title = value.title || "-"; + var titles = title.split(/【|[0-9]*】/); + var category = titles.length>2?titles[1]:'-'; + + value.title = title; + value.category = category; + value.idx = idx; + value.year = value.year || 180; + + if(!(category in list)){ + list[category] = {}; + } + + list[category][idx] = value; + }); + + var $select = $('#scenario_sel'); + $.each(list, function(category, items){ + var $optgroup = $('').attr('label', category); + + $.each(items, function(idx, scenario){ + var $option = $('