Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
3,282 additions
and
2,944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.3.9 | ||
1.3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#include "emissive-blend.h" | ||
|
||
#include "user-interface/constants.h" | ||
#include "errors.h" | ||
#include "logging/logging.h" | ||
#include "utilities/strings.h" | ||
|
||
bool emissiveblend::hasChanged(Ui::MainWindow *ui) | ||
{ | ||
// simplifying default checks | ||
#define START return ( | ||
#define VAL(w, s) stripZeroes(w->cleanText()) != s || | ||
#define CHE(w) w->isChecked() || | ||
#define COL(w) utils::getBG(w) != white || | ||
#define TEX(w) w->text() != "" || | ||
#define END false); | ||
|
||
START | ||
TEX(ui->lineEdit_emissiveBlendTexture) | ||
TEX(ui->lineEdit_emissiveBlendBaseTexture) | ||
TEX(ui->lineEdit_emissiveBlendFlowTexture) | ||
VAL(ui->doubleSpinBox_emissiveBlendScrollX, "0.0") | ||
VAL(ui->doubleSpinBox_emissiveBlendScrollY, "0.0") | ||
VAL(ui->doubleSpinBox_emissiveBlendStrength, "1.0") | ||
COL(ui->toolButton_emissiveBlendTint) | ||
END | ||
} | ||
|
||
void emissiveblend::resetAction(Ui::MainWindow *ui) | ||
{ | ||
ui->groupBox_emissiveBlend->setVisible(false); | ||
ui->action_emissiveBlend->setChecked(false); | ||
} | ||
|
||
void emissiveblend::resetWidgets(Ui::MainWindow *ui) | ||
{ | ||
ui->lineEdit_emissiveBlendTexture->clear(); | ||
ui->lineEdit_emissiveBlendBaseTexture->clear(); | ||
ui->lineEdit_emissiveBlendFlowTexture->clear(); | ||
ui->toolButton_emissiveBlendTint->setStyleSheet(whiteBG); | ||
ui->doubleSpinBox_emissiveBlendTint->setValue(1.0); | ||
ui->doubleSpinBox_emissiveBlendScrollX->setValue(0.0); | ||
ui->doubleSpinBox_emissiveBlendScrollY->setValue(0.0); | ||
} | ||
|
||
void initializeEmissiveBlend(Ui::MainWindow *ui, VmtFile *vmt) | ||
{ | ||
utils::BooleanResult raw = utils::takeBoolean("$emissiveblendenabled", vmt, ui); | ||
if (!raw.present) | ||
return; | ||
|
||
vmt->state.showEmissiveBlend = true; | ||
|
||
switch (vmt->shader) | ||
{ | ||
case Shader::S_VertexLitGeneric: | ||
ui->groupBox_emissiveBlend->setEnabled(true); | ||
ui->groupBox_emissiveBlend->setChecked(true); | ||
vmt->state.emissiveBlendEnabled = true; | ||
break; | ||
default: | ||
ERROR("Emissive blend only works with the VertexLitGeneric shader"); | ||
} | ||
} | ||
|
||
void processScrollVector(const QString ¶meter, const QString &value, | ||
Ui::MainWindow *ui) | ||
{ | ||
const utils::DoubleTuple tuple = utils::toDoubleTuple(value, 2); | ||
|
||
if (tuple.valid) { | ||
double xd = tuple.values.at(0); | ||
double yd = tuple.values.at(1); | ||
ui->doubleSpinBox_emissiveBlendScrollX->setValue(xd); | ||
ui->doubleSpinBox_emissiveBlendScrollY->setValue(yd); | ||
} else { | ||
logging::error(parameter + " has invalid value: " + value, | ||
ui); | ||
} | ||
} | ||
|
||
void emissiveblend::parseParameters(Ui::MainWindow *ui, VmtFile *vmt, MainWindow *mainwindow) | ||
{ | ||
// golfing away the checks to quickly parse parameters | ||
// note that the DO... macros all require an additional end bracket as | ||
// PREP opens an if | ||
#define PREP(p) \ | ||
if (vmt->parameters.contains(p)) { \ | ||
if (!vmt->state.emissiveBlendEnabled) \ | ||
ERROR(p " only works with $emissiveblendenabled 1") \ | ||
vmt->state.showEmissiveBlend = true; | ||
#define DO(p, m) { \ | ||
PREP(p) \ | ||
m(p, vmt->parameters.take(p), ui); \ | ||
} \ | ||
} | ||
#define DO_CHOICE(p, m, b) { \ | ||
PREP(p) \ | ||
m(p, vmt->parameters.take(p), ui, b); \ | ||
} \ | ||
} | ||
#define DO_WITH_VMT(p, m) { \ | ||
PREP(p) \ | ||
m(p, vmt->parameters.take(p), ui, *vmt); \ | ||
} \ | ||
} | ||
#define DOUBLE(p, def, widget) { \ | ||
PREP(p) \ | ||
const QString &v = vmt->parameters.take(p); \ | ||
utils::DoubleResult r = \ | ||
utils::parseDouble(p, v, def, ui); \ | ||
if (r.notDefault) widget->setValue(r.value); \ | ||
} \ | ||
} | ||
#define BOOL(p, widget) { \ | ||
PREP(p) \ | ||
const QString &v = vmt->parameters.take(p); \ | ||
utils::BooleanResult r = \ | ||
utils::parseBoolean(p, v, ui); \ | ||
if (r.value) widget->setChecked(true); \ | ||
} \ | ||
} | ||
#define COLOR(p, color, slider) { \ | ||
PREP(p) \ | ||
const QString &v = vmt->parameters.take(p); \ | ||
utils::applyColor(p, v, color, slider, ui); \ | ||
} \ | ||
} | ||
#define TEXTURE(p, widget) { \ | ||
PREP(p) \ | ||
const QString &v = vmt->parameters.take(p); \ | ||
utils::parseTexture(p, v, ui, widget, *vmt); \ | ||
mainwindow->createReconvertAction(widget, v); \ | ||
} \ | ||
} | ||
|
||
initializeEmissiveBlend(ui, vmt); | ||
|
||
DO("$emissiveblendscrollvector", processScrollVector) | ||
TEXTURE("$emissiveblendtexture", ui->lineEdit_emissiveBlendTexture) | ||
TEXTURE("$emissiveblendbasetexture", ui->lineEdit_emissiveBlendBaseTexture) | ||
TEXTURE("$emissiveblendflowtexture", ui->lineEdit_emissiveBlendFlowTexture) | ||
COLOR("$emissiveblendtint", ui->toolButton_emissiveBlendTint, ui->doubleSpinBox_emissiveBlendTint) | ||
DOUBLE("$emissiveblendstrength", "1", ui->doubleSpinBox_emissiveBlendStrength) | ||
DOUBLE("$bumpdetailscale2", "1", ui->doubleSpinBox_bumpdetailscale2) | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef EMISSIVEBLEND_H | ||
#define EMISSIVEBLEND_H | ||
|
||
#include "ui_mainwindow.h" | ||
|
||
#include "view-helper.h" | ||
#include "vmt/vmt-helper.h" | ||
|
||
/*! | ||
* Functions for interacting with the Normal blend named groupbox. | ||
*/ | ||
namespace emissiveblend { | ||
|
||
/*! | ||
* Detects if the views are not in their default state and returns true if | ||
* any field differs from the default. | ||
* | ||
* Call from MainWindow::isGroupChanged(). | ||
*/ | ||
bool hasChanged(Ui::MainWindow *ui); | ||
|
||
/*! | ||
* Hides the groupbox and unchecks the action. | ||
* | ||
* Call from MainWindow::shaderChanged() for hiding group boxes whose | ||
* content did not change after a shader change. | ||
*/ | ||
void resetAction(Ui::MainWindow *ui); | ||
|
||
/*! | ||
* Resets the widgets to their default state. | ||
* | ||
* Call from MainWindow::resetWidgets(). | ||
*/ | ||
void resetWidgets(Ui::MainWindow *ui); | ||
|
||
/*! | ||
* Processes the passed parameter from the VmtFile and initializes the | ||
* user interface with it. | ||
* | ||
* Checks vmt->state.normalBlendEnabled. | ||
* | ||
* The user interface is set up and errors are returned should any | ||
* parameters have an invalid format. | ||
* | ||
* We only process the parameter if it exists. | ||
*/ | ||
void parseParameters(Ui::MainWindow *ui, VmtFile *vmt, MainWindow *mainwindow); | ||
|
||
} // namespace normalblend | ||
|
||
#endif |
Oops, something went wrong.