Skip to content

Commit 6897403

Browse files
author
noodlefighter
committed
修复创建用户UI时读取配置的行为,原先从ini中取出初始配置,改为从opts实例中读取;修复ini类型,它只是Object,而opts才是LabelPlusInputOptions类型的对象
1 parent c19e797 commit 6897403

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

src/main.ts

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class LabelPlusInput extends GenericUI {
119119
//
120120
// 用户界面构建
121121
//
122-
LabelPlusInput.prototype.createPanel = function (pnl: any, ini: LabelPlusInputOptions) {
122+
LabelPlusInput.prototype.createPanel = function (pnl: any, ini: any) {
123123
let self = this;
124124
let opts = new LabelPlusInputOptions(ini);// default values
125125

@@ -465,82 +465,78 @@ LabelPlusInput.prototype.createPanel = function (pnl: any, ini: LabelPlusInputOp
465465
pnl.overlayGroupTextBox = pnl.add('edittext', [xx, yy, xx + 180, yy + 20]);
466466
pnl.overlayGroupTextBox.enabled = false;
467467

468-
if (ini == undefined) { // if there was an ini object
469-
ini = new LabelPlusInputOptions(undefined);
470-
}
471-
472468
//------------------读取配置区------------------
473469
//文本替换
474-
if (ini.textReplace) {
470+
if (opts.textReplace) {
475471
pnl.textReplaceCheckBox.value = true;
476472
pnl.textReplaceTextBox.enabled = true;
477473
pnl.textReplaceTextBox.text = opts.textReplace;
478474
}
479475

480476
// 字体
481-
if (ini.setFont) {
477+
if (opts.setFont) {
482478
pnl.setFontCheckBox.value = true;
483479
pnl.font.family.enabled = true;
484480
pnl.font.style.enabled = true;
485481
pnl.font.fontSize.enabled = true;
486-
pnl.font.setFont(ini.font, ini.fontSize);
482+
pnl.font.setFont(opts.font, opts.fontSize);
487483
}
488484

489485
// 行距
490-
if (ini.setTextLeading) {
491-
pnl.setTextLeadingCheckBox.value = ini.setTextLeading;
492-
pnl.textLeadingTextBox.enabled = ini.setTextLeading;
486+
if (opts.setTextLeading) {
487+
pnl.setTextLeadingCheckBox.value = opts.setTextLeading;
488+
pnl.textLeadingTextBox.enabled = opts.setTextLeading;
493489
}
494-
if (ini.textLeading) {
495-
pnl.textLeadingTextBox.text = ini.textLeading;
490+
if (opts.textLeading) {
491+
pnl.textLeadingTextBox.text = opts.textLeading;
496492
}
497493

498494
// 导出标号选项
499-
if (ini.outputLabelNumber) {
500-
pnl.outputLabelNumberCheckBox.value = ini.outputLabelNumber;
495+
if (opts.outputLabelNumber) {
496+
pnl.outputLabelNumberCheckBox.value = opts.outputLabelNumber;
501497
}
502498

503499
// 输出横排文字
504-
if (ini.horizontalText) {
505-
pnl.outputHorizontalCheckBox.value = ini.horizontalText;
500+
if (opts.horizontalText) {
501+
pnl.outputHorizontalCheckBox.value = opts.horizontalText;
506502
}
507503
// 处理无标号文档
508-
if (ini.outputNoSignPsd) {
509-
pnl.outputNoSignPsdCheckBox.value = ini.outputNoSignPsd;
504+
if (opts.outputNoSignPsd) {
505+
pnl.outputNoSignPsdCheckBox.value = opts.outputNoSignPsd;
510506
}
511507

512508
// 无视LabelPlus文本中的图源文件名
513-
if (ini.ignoreImgFileName) {
509+
if (opts.ignoreImgFileName) {
514510
pnl.ignoreImgFileNameCheckBox.value = true;
515511
}
516512

517513
// 使用指定类型图源
518-
if (ini.sourceFileType) {
514+
if (opts.sourceFileType) {
519515
pnl.setSourceFileTypeCheckBox.value = true;
520516
pnl.setSourceFileTypeList.enabled = true;
521-
pnl.setSourceFileTypeList.selection.text = ini.sourceFileType;
517+
pnl.setSourceFileTypeList.selection.text = opts.sourceFileType;
522518
}
523519

524520
// 执行动作GroupN
525-
if (ini.runActionGroup) {
521+
if (opts.runActionGroup) {
526522
pnl.runActionGroupCheckBox.value = true;
527523
pnl.runActionGroupList.enabled = true;
528-
pnl.runActionGroupList.selection.text = ini.runActionGroup;
524+
pnl.runActionGroupList.selection.text = opts.runActionGroup;
529525
}
530526

531527
// 导入后不关闭文档
532-
if (ini.notClose)
528+
if (opts.notClose)
533529
pnl.notCloseCheckBox.value = true;
534530

535531
// 不对图层进行分组
536-
if (ini.layerNotGroup)
532+
if (opts.layerNotGroup)
537533
pnl.layerNotGroupCheckBox.value = true;
538534

539535
// 涂白
540-
if (ini.overloayGroup) {
536+
if (opts.overloayGroup) {
541537
pnl.overlayCheckBox.value = true;
542538
pnl.overlayGroupTextBox.enabled = true;
543-
pnl.overlayGroupTextBox.text = ini.overloayGroup;
539+
pnl.overlayGroupTextBox.text = opts.overloayGroup;
544540
}
545541

546542
return pnl;
@@ -549,7 +545,7 @@ LabelPlusInput.prototype.createPanel = function (pnl: any, ini: LabelPlusInputOp
549545
//
550546
// 自定义读取配框
551547
//
552-
let createSettingsPanel = function (pnl: any, ini: LabelPlusInputOptions) {
548+
let createSettingsPanel = function (pnl: any, ini: any) {
553549
let win = GenericUI.getWindow(pnl.parent);
554550

555551
pnl.text = i18n.LABEL_SETTING;
@@ -662,7 +658,7 @@ let createSettingsPanel = function (pnl: any, ini: LabelPlusInputOptions) {
662658
//
663659
// 读出用户UI数据
664660
//
665-
LabelPlusInput.prototype.validatePanel = function (pnl: any, ini: LabelPlusInputOptions, tofile: boolean) :LabelPlusInputOptions {
661+
LabelPlusInput.prototype.validatePanel = function (pnl: any, ini: any, tofile: boolean) :LabelPlusInputOptions {
666662
let self = this;
667663
let opts = new LabelPlusInputOptions(ini);
668664

@@ -717,7 +713,7 @@ LabelPlusInput.prototype.validatePanel = function (pnl: any, ini: LabelPlusInput
717713
return self.errorPrompt(i18n.ERROR_NOTCHOOSEIMAGE);
718714
else {
719715
let sortedImgSelection = pnl.chooseImageListBox.selection.sort();
720-
opts.imageSelected = []; //new Array(); //todo:
716+
opts.imageSelected = [];
721717

722718
for (let i = 0; i < sortedImgSelection.length; i++) {
723719
opts.imageSelected[i] = {
@@ -1113,7 +1109,7 @@ let iniToString = function (ini) {
11131109
return str;
11141110
};
11151111

1116-
let writeIni = function (iniFile: string, ini: LabelPlusInputOptions) {
1112+
let writeIni = function (iniFile: string, ini: any) {
11171113
//$.level = 1; debugger;
11181114
if (!ini || !iniFile) {
11191115
return;
@@ -1137,7 +1133,7 @@ let writeIni = function (iniFile: string, ini: LabelPlusInputOptions) {
11371133
//
11381134
// 读出配置
11391135
//
1140-
let readIni = function (iniFile: string, ini ?: LabelPlusInputOptions): LabelPlusInputOptions {
1136+
let readIni = function (iniFile: string, ini ?: any): LabelPlusInputOptions {
11411137
//$.level = 1; debugger;
11421138

11431139
if (!ini) {

0 commit comments

Comments
 (0)