1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-01-18 12:15:27 +00:00

Finally introducing texture scaling.

This commit is contained in:
Filippo Scognamiglio 2014-04-20 22:59:46 +02:00
parent 01b5dd9651
commit 1ef94e083c
8 changed files with 54 additions and 49 deletions

View File

@ -28,7 +28,7 @@ Window {
id: settings_window
title: qsTr("Settings")
width: 640
height: 460
height: 480
modality: Qt.ApplicationModal
@ -147,17 +147,6 @@ Window {
onValueChanged: shadersettings.brightness = value
value: shadersettings.brightness
}
//TODO decide later what to do with scaling
// SimpleSlider{
// name: "Terminal Scaling"
// onValueChanged: shadersettings.terminal_scaling = value
// value: shadersettings.terminal_scaling
// }
// SimpleSlider{
// name: "Window Scaling"
// onValueChanged: shadersettings.window_scaling = value
// value: shadersettings.window_scaling
// }
}
}
GroupBox{
@ -166,10 +155,10 @@ Window {
Layout.columnSpan: 2
anchors.left: parent.left
anchors.right: parent.right
RowLayout{
GridLayout{
columns: 3
Layout.columnSpan: 2
anchors.left: parent.left
anchors.right: parent.right
anchors {left: parent.left; right: parent.right}
Text{text: "Animation FPS"}
Slider{
Layout.fillWidth: true
@ -180,10 +169,19 @@ Window {
onValueChanged: shadersettings.fps = value;
value: shadersettings.fps
}
Text{
id: textfield
text: slider.value
Text{text: slider.value}
Text{text: "Texture quality"}
Slider{
Layout.fillWidth: true
id: txtslider
stepSize: 0.01
maximumValue: 1
minimumValue: 0
onValueChanged: shadersettings.window_scaling = value;
value: shadersettings.window_scaling
updateValueWhileDragging: false
}
Text{text: Math.round(txtslider.value * 100) + "%"}
}
}
}

View File

@ -41,10 +41,11 @@ ShaderEffect {
property real horizontal_sincronization: shadersettings.horizontal_sincronization
property bool frame_reflection_strength: shadersettings.frame_reflection_strength
property real disp_top: frame.item.displacementTop.toFixed(1)
property real disp_bottom: frame.item.displacementBottom
property real disp_left: frame.item.displacementLeft
property real disp_right: frame.item.displacementRight
property real disp_top: frame.item.displacementTop * shadersettings.window_scaling
property real disp_bottom: frame.item.displacementBottom * shadersettings.window_scaling
property real disp_left: frame.item.displacementLeft * shadersettings.window_scaling
property real disp_right: frame.item.displacementRight * shadersettings.window_scaling
property real brightness: shadersettings.brightness * 1.5 + 0.5

View File

@ -27,15 +27,11 @@ Item{
property real contrast: 0.85
property real brightness: 0.75
//On resize shows an overlay with the current size
property bool show_terminal_size: true
//Scaling of the preprocessed terminal with respect to the window.
property real terminal_scaling: 1.0
onTerminal_scalingChanged: handleFontChanged();
//Scaling of the whole window
property real window_scaling: 1.0
property real total_scaling: terminal_scaling * window_scaling
onWindow_scalingChanged: handleFontChanged();
property real fps: 60
@ -172,6 +168,7 @@ Item{
show_terminal_size = settings.show_terminal_size ? settings.show_terminal_size : show_terminal_size
fps = settings.fps !== undefined ? settings.fps: fps
window_scaling = settings.window_scaling ? settings.window_scaling : window_scaling
contrast = settings.contrast !== undefined ? settings.contrast : contrast;
brightness = settings.brightness !== undefined ? settings.brightness : brightness
@ -201,6 +198,7 @@ Item{
function storeCurrentSettings(){
var settings = {
fps: fps,
window_scaling: window_scaling,
show_terminal_size: show_terminal_size,
ambient_light: ambient_light,
brightness: brightness,

View File

@ -85,7 +85,7 @@ Item{
onUpdatedImage: {blurredSource.live = true;livetimer.restart();}
Component.onCompleted: {
var scaling_factor = shadersettings.font_scaling * shadersettings.terminal_scaling * shadersettings.window_scaling;
var scaling_factor = shadersettings.font_scaling * shadersettings.window_scaling;
font.pointSize = shadersettings.font.pixelSize * scaling_factor;
font.family = shadersettings.font.name;
setLineSpacing(shadersettings.font.lineSpacing);
@ -160,6 +160,9 @@ Item{
recursive: true
live: true
smooth: false
antialiasing: false
Timer{
id: livetimer
running: true

View File

@ -13,10 +13,9 @@ TerminalFrame{
borderBottom: 232
imageSource: "../images/black-frame.png"
normalsSource: "../images/black-frame-normals.png"
sourceRect: Qt.rect(-20 * shadersettings.total_scaling,
-20 * shadersettings.total_scaling,
terminal.width + 40 * shadersettings.total_scaling,
terminal.height + 40 * shadersettings.total_scaling)
rectX: 20
rectY: 20
distortionCoefficient: 1.9

View File

@ -13,10 +13,9 @@ TerminalFrame{
borderBottom: 116
imageSource: "../images/screen-frame.png"
normalsSource: "../images/screen-frame-normals.png"
sourceRect: Qt.rect(-15 * shadersettings.total_scaling,
-15 * shadersettings.total_scaling,
terminal.width + 30 * shadersettings.total_scaling,
terminal.height+ 30 * shadersettings.total_scaling)
rectX: 15
rectY: 15
distortionCoefficient: 1.5

View File

@ -13,6 +13,10 @@ Item{
property rect sourceRect
property string shaderString
//Value used to create the rect used to add the border to the texture
property real rectX
property real rectY
//Values used to displace the texture in the screen. Used to make reflections correct.
property real displacementLeft
property real displacementTop

View File

@ -90,7 +90,10 @@ ApplicationWindow{
Loader{
id: frame
property rect sourceRect: item.sourceRect
property rect sourceRect: Qt.rect(-item.rectX * shadersettings.window_scaling,
-item.rectY * shadersettings.window_scaling,
terminal.width + 2*item.rectX * shadersettings.window_scaling,
terminal.height + 2*item.rectY * shadersettings.window_scaling)
anchors.fill: parent
z: 2.1
source: shadersettings.frame_source
@ -133,8 +136,8 @@ ApplicationWindow{
anchors.centerIn: parent
property int frameOffsetX: frame.item.addedWidth - frame.item.borderLeft - frame.item.borderRight
property int frameOffsetY: frame.item.addedHeight - frame.item.borderTop - frame.item.borderBottom
width: (parent.width + frameOffsetX) * shadersettings.terminal_scaling
height: (parent.height + frameOffsetY) * shadersettings.terminal_scaling
width: parent.width + frameOffsetX * shadersettings.window_scaling
height: parent.height + frameOffsetY * shadersettings.window_scaling
}
ShaderEffectSource{
id: theSource
@ -146,15 +149,6 @@ ApplicationWindow{
anchors.fill: parent
z: 1.9
}
Loader{
id: sizeoverlayloader
z: 3
anchors.centerIn: parent
active: shadersettings.show_terminal_size
sourceComponent: SizeOverlay{
terminalSize: terminal.terminalSize
}
}
}
ShaderSettings{
id: shadersettings
@ -166,4 +160,13 @@ ApplicationWindow{
id: settingswindow
visible: false
}
Loader{
id: sizeoverlayloader
z: 3
anchors.centerIn: parent
active: shadersettings.show_terminal_size
sourceComponent: SizeOverlay{
terminalSize: terminal.terminalSize
}
}
}