Add: LicenseDataManager

This commit is contained in:
2018-12-12 00:01:40 +09:00
parent 0733a79630
commit 750887d5d1
4 changed files with 152 additions and 34 deletions
+30 -19
View File
@@ -1,5 +1,6 @@
function InputScore(chart) {
this.chart = chart;
this.licenseDataManager = new LicenseDataManager();
this.initVariables();
@@ -31,8 +32,8 @@ function InputScore(chart) {
var subjectTextSetting = this.makeInputTextSetting(280, "과목 입력");
this.subjectText = this.makeInputText(120, this.inputScorePosY + 10, subjectTextSetting);
this.subjectText.setText(this.subject);
this.subjectFullnameText = this.makeInputText(120, this.inputScorePosY + 10, subjectTextSetting);
this.setSubjectFullname(this.subjectFullname);
var titleTextStyle = { font: "36px Arial", fill: "#fff", align: "center"};
this.titleText = game.add.text(440, this.inputScorePosY + 40, "점수", titleTextStyle);
@@ -60,7 +61,7 @@ function InputScore(chart) {
(function() { this.onClickSendToServerButton(); }).bind(this)
);
this.loadLicenseCompanySubjectData();
// this.loadLicenseCompanySubjectData();
this.makeLicenseCompanySubjectPanel();
this.setVisibleLicenseCompanyPanel(false);
this.setVisibleLicenseSubjectPanel(false, "");
@@ -69,8 +70,8 @@ function InputScore(chart) {
InputScore.prototype.initVariables = function() {
this.inputScorePosY = GAME_SCREEN_SIZE.y - InputScore.INPUT_SCORE_GROUP_OFFSET_Y;
this.subject = "ITQ 파워포인트";
this.recentSubject = this.subject;
this.subjectFullname = "ITQ 파워포인트";
this.recentSubject = this.subjectFullname;
this.licenseCompanyButtonList = [];
this.licenseSubjectButtonList = [];
@@ -103,7 +104,11 @@ InputScore.prototype.makeInputText = function(x, y, setting) {
return inputText;
}
InputScore.prototype.setSubjectFullname = function(fullname) {
this.subjectFullname = fullname;
// this.subjectFullnameText.text = fullname;
this.subjectFullnameText.setText(this.subjectFullname);
}
InputScore.prototype.onClickSubjectButton = function() {
if(!this.licenseCompanyPanel.visible)
@@ -116,9 +121,10 @@ InputScore.prototype.onClickSubjectButton = function() {
/*
InputScore.prototype.loadLicenseCompanySubjectData = function() {
this.licenseCompanies = [];
this.licenseCompanySubjects = [];
this.licenseSubjects = [];
// console.log(licenseCompanySubjectList);
this.maxSubjectCount = 0;
@@ -143,7 +149,7 @@ InputScore.prototype.loadLicenseCompanySubjectData = function() {
companyData.subjectData[j].gradeList
);
this.licenseCompanySubjects.push(licenseCompnaySubjectItem);
this.licenseSubjects.push(licenseCompnaySubjectItem);
}
}
@@ -153,12 +159,14 @@ InputScore.prototype.loadLicenseCompanySubjectData = function() {
}
// console.log(this.licenseCompanies);
// console.log(this.licenseCompanySubjects);
// console.log(this.licenseSubjects);
// console.log(this.maxSubjectCount);
}
*/
InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
var buttonStackCount = Math.floor(licenseCompanySubjectList.length / 7) + 1;
var companyCount = this.licenseDataManager.getCompanyCount();
var buttonStackCount = Math.floor(companyCount / 7) + 1;
var gapWidth = 10;
var licenseCompanyPanelWidth = gapWidth + (InputScore.LICENSE_COMPANY_BUTTON_WIDTH + gapWidth) * buttonStackCount;
@@ -189,11 +197,11 @@ InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
setting.fontStyle.fontWeight = "bold";
// license company buttons
for(var i = 0; i < licenseCompanySubjectList.length; i++) {
for(var i = 0; i < companyCount; i++) {
setting.width = InputScore.LICENSE_COMPANY_BUTTON_WIDTH;
var self = this;
var companyName = licenseCompanySubjectList[i].companyName;
var companyName = this.licenseDataManager.getCompanyName(i);
this.licenseCompanyButtonList[i] = new RoundRectButton(
setting, null, companyName,
(function() { self.setVisibleLicenseSubjectPanel(true, this.text.text); })
@@ -201,10 +209,11 @@ InputScore.prototype.makeLicenseCompanySubjectPanel = function() {
}
// license subject buttons
for(var i = 0; i < this.licenseCompanySubjects.length; i++) {
var subjectCount = this.licenseDataManager.getSubjectCount();
for(var i = 0; i < subjectCount; i++) {
setting.width = InputScore.LICENSE_SUBJECT_BUTTON_WIDTH;
var companySubjectData = this.licenseCompanySubjects[i];
var companySubjectData = this.licenseDataManager.getSubjectDataByIndex(i);
var companySubjectName = companySubjectData.companyName + " " + companySubjectData.subjectName;
this.licenseSubjectButtonList[i] = new RoundRectButton(setting, null, companySubjectName, null);
}
@@ -250,8 +259,9 @@ InputScore.prototype.setVisibleLicenseSubjectPanel = function(flag, companyName)
return;
var buttonIndex = 0;
for(var i = 0; i < this.licenseCompanySubjects.length; i++) {
var subjectData = this.licenseCompanySubjects[i];
var subjectCount = this.licenseDataManager.getSubjectCount();
for(var i = 0; i < subjectCount; i++) {
var subjectData = this.licenseDataManager.getSubjectDataByIndex(i);
if(subjectData.companyName == companyName) {
var button = this.licenseSubjectButtonList[buttonIndex];
@@ -273,8 +283,7 @@ InputScore.prototype.setVisibleLicenseSubjectPanel = function(flag, companyName)
}
InputScore.prototype.onClickCompanySubjectButton = function(companySubjectName) {
console.log(companySubjectName);
// this.subjectText.setText(companySubjectName);
this.setSubjectFullname(companySubjectName);
}
@@ -305,10 +314,12 @@ InputScore.LICENSE_BUTTON_GAP_HEIGHT = 64;
InputScore.LICENSE_SUBJECT_BUTTON_MAX_COUNT = 6;
/*
function LicenseCompanySubjectData(companyName, subjectName, timeLimit, maxScore, gradeList) {
this.companyName = companyName;
this.subjectName = subjectName;
this.timeLimit = timeLimit;
this.maxScore = maxScore;
this.gradeList = gradeList;
}
}
*/