Compare commits

...

4 commits

11 changed files with 448 additions and 165 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
main
Blk_Jack

13
Blk_Jack.nimble Normal file
View file

@ -0,0 +1,13 @@
# Package
version = "0.69"
author = "Prince"
description = "a BlackJack helper made with qml written in nim"
license = "GPL-3.0"
srcDir = "src"
bin = @["Blk_Jack"]
# Dependencies
requires "nim >= 1.2.0, nimqml >= 0.9.0"

182
LICENSE
View file

@ -1,9 +1,181 @@
MIT License
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (c) 2024 prince
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
--------------------------------------------------------------------------------
SPECIAL EXCEPTION GRANTED BY COPYRIGHT HOLDERS
As a special exception, copyright holders give you permission to link this
library with independent modules to produce an executable, regardless of
the license terms of these independent modules, and to copy and distribute
the resulting executable under terms of your choice, provided that you also
meet, for each linked independent module, the terms and conditions of
the license of that module. An independent module is a module which is not
derived from or based on this library. If you modify this library, you must
extend this exception to your version of the library.
Note: this exception relieves you of any obligations under sections 4 and 5
of this license, and section 6 of the GNU General Public License.

149
main.qml
View file

@ -1,149 +0,0 @@
import QtQuick 6
import QtQuick.Controls 6
import QtQuick.Layouts 6
ApplicationWindow {
width: 600
height: 501
title: "BJ Helper ;)"
Component.onCompleted: visible = true
Image{ // setting background img properties
id: backg
anchors.centerIn: parent
width: parent.width
height: parent.height
source: "bg.jpg"
}
SplitView{ // setting up a SplitView that has 2 rectangles
orientation: Qt.Vertical
anchors.fill: parent
Rectangle{
id: rect1
SplitView.preferredHeight: parent.height - 190 // setting the bar to be 60 ambiguous units lower than middle
Layout.maximumHeight: 500
color: "transparent"
//textfeild time
GridLayout{
id: grid1
anchors.fill: parent
columns: 6
rows: 5
flow: GridLayout.TopToBottom
Layout.fillWidth: false
Layout.preferredWidth: 200
//start of name boxes
Repeater{
id: names
model: ["name", "name", "name", "name", "name"]
TextField { // look at my field of TextFields
required property string modelData
id: na1
placeholderText: modelData
background: Rectangle {
implicitWidth: 175
implicitHeight: 35
color: na1.enabled ? "transparent" : "#353637"
border.color: na1.enabled ? "#87CEEB" : "transparent"
}
}
}
//start of bet boxes
Repeater{
id: bets
model: 5
TextField{
id: bt1
placeholderText: qsTr("Enter bet")
background: Rectangle {
implicitWidth: 175
implicitHeight: 35
color: bt1.enabled ? "transparent" : "#353637"
border.color: bt1.enabled ? "#87CEEB" : "transparent"
}
}
}
//start of Push buttons
Repeater{
model: 5
RoundButton{
id: p1
text: "P"
background: Rectangle{
implicitHeight: 35
implicitWidth: 35
color: p1.down ? "#eddc1c" : "transparent"
border.color: "#eddc1c"
border.width: 1
radius: 180
}
}
}
//start od Double buttons
Repeater{
model: 5
RoundButton{
id: d1
text: "D"
background: Rectangle{
implicitHeight: 35
implicitWidth: 35
color: d1.down ? "#7207ed" : "transparent"
border.color: "#7207ed"
border.width: 1
radius: 180
}
}
}
//start of Win buttons
Repeater{
model: 5
RoundButton{
id: w1
text: "W"
background: Rectangle{
implicitHeight: 35
implicitWidth: 35
color: w1.down ? "#1dbf32" : "transparent"
border.color: "#1dbf32"
border.width: 1
radius: 180
}
}
}
//start of Lose buttons
Repeater{
model: 5
RoundButton{
id: l1
text: "L"
background: Rectangle{
implicitHeight: 35
implicitWidth: 35
color: l1.down ? "#e6050c" : "transparent"
border.color: "#e6050c"
border.width: 1
radius: 180
}
}
}
}
}
Rectangle{
id: rect2
//SplitView.preferredHeight: parent.height - 300 // not needed as it conflicts with rect1 line placement
Layout.maximumHeight: 500
color: "#2b2b29" //making payout window grey for better visibility
ListView{
model: names
}
}
}
}

2
notes
View file

@ -1,2 +0,0 @@
Push should be yellow w is green l is red
Double can be purple cause favorite color

View file

@ -7,7 +7,7 @@ proc mainProc() =
var engine = newQQmlApplicationEngine()
defer: engine.delete()
engine.load("main.qml")
engine.load("src/main.qml")
app.exec()
when isMainModule:

View file

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 177 KiB

43
src/main.qml Normal file
View file

@ -0,0 +1,43 @@
import QtQuick 6
import QtQuick.Controls 6
import QtQuick.Layouts 6
import "players"
ApplicationWindow {
width: 600
height: 501
title: "BJ Helper ;)"
Component.onCompleted: visible = true
Image{ // setting background img properties
id: backg
anchors.centerIn: parent
width: parent.width
height: parent.height
source: "bg.jpg"
}
SplitView{ // setting up a SplitView that has 2 rectangles
orientation: Qt.Vertical
anchors.fill: parent
Rectangle{
id: rect1
SplitView.preferredHeight: parent.height - 190 // setting the bar to be 60 ambiguous units lower than middle
Layout.maximumHeight: 500
color: "transparent"
Player0{}
}
Rectangle{
id: rect2
//SplitView.preferredHeight: parent.height - 300 // not needed as it conflicts with rect1 line placement
Layout.maximumHeight: 500
color: "#2b2b29" //making payout window grey for better visibility
}
}
}

109
src/player.nim Normal file
View file

@ -0,0 +1,109 @@
import NimQml
QtObject:
type player* = ref object of QObject
p_name: string
p_bet: int
p_push: bool
p_double: bool
p_payout: int
proc delete*(self: player)
proc setup(self: player)
proc newplayer*(): player =
new(result, delete)
result.p_name = "no player name"
result.p_bet = 250000
result.p_push = false
result.p_double = false
result.p_payout = 250000
result.setup
proc delete*(self: player) =
self.QObject.delete
proc setup(self: player) =
self.QObject.setup
proc getName*(self: player): string {.slot.} =
result = self.p_name
proc getBet*(self: player): int {.slot.} =
result = self.p_bet
proc getPush*(self: player): bool {.slot.} =
result = self.p_push
proc getDouble*(self: player): bool {.slot.} =
result = self.p_double
proc getPayout*(self: player): int {.slot.} =
result = self.p_payout
proc nameChanged*(self: player, name: string) {.signal.}
proc betChanged*(self: player, bet: int) {.signal.}
proc pushChanged*(self: player, push: bool) {.signal.}
proc doubleChanged*(self: player, double: bool) {.signal.}
proc payoutChanged*(self: player, payout: int) {.signal.}
proc setName*(self: player, name: string) {.slot.} =
if self.p_name == name:
return
self.p_name = name
self.nameChanged(name)
proc setBet*(self: player, bet: int) {.slot.} =
if self.p_bet == bet:
return
self.p_bet = bet
self.betChanged(bet)
proc setPush*(self: player, push: bool) {.slot.} =
if self.p_push == push:
return
self.p_push = push
self.pushChanged(push)
proc setDouble*(self: player, double: bool) {.slot.} =
if self.p_double == double:
return
self.p_double = double
self.doubleChanged(double)
proc setPayout*(self: player, payout: int) {.slot.} =
if self.p_payout == payout:
return
self.p_payout = payout
self.payoutChanged(payout)
proc calcPayout*(self: player, bet: int, push: bool, double: bool): int {.slot.} =
var payout = bet * 2
self.p_bet = payout
self.betChanged(payout)
QtProperty[string] name:
read = getName
write = setName
notify = nameChanged
QtProperty[int] bet:
read = getBet
write = setBet
notify = betChanged
QtProperty[bool] push:
read = getPush
write = setPush
notify = pushChanged
QtProperty[bool] double:
read = getDouble
write = setDouble
notify = doubleChanged
QtProperty[int] payout:
read = getPayout
write = setPayout
notify = payoutChanged

103
src/players/Player0.qml Normal file
View file

@ -0,0 +1,103 @@
import QtQuick 6
import QtQuick.Controls 6
import QtQuick.Layouts 6
RowLayout{
anchors.fill: parent
spacing: 2
TextField { // look at my field of TextFields
id: na1
Layout.fillWidth: true
Layout.maximumWidth: parent.width / 2.5
placeholderText: "enter playername"
background: Rectangle {
implicitWidth: 175
implicitHeight: 35
color: na1.enabled ? "transparent" : "#353637"
border.color: na1.enabled ? "#87CEEB" : "transparent"
}
}
TextField {
id: bt1
Layout.fillWidth: true
Layout.maximumWidth: parent.width / 2.5
placeholderText: qsTr("Enter bet")
background: Rectangle {
implicitWidth: 175
implicitHeight: 35
color: bt1.enabled ? "transparent" : "#353637"
border.color: bt1.enabled ? "#87CEEB" : "transparent"
}
}
RoundButton {
id: p1
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: parent.width / 8
Layout.maximumHeight: parent.height / 8
text: "P"
background: Rectangle {
implicitHeight: 35
implicitWidth: 35
color: p1.down ? "#eddc1c" : "transparent"
border.color: "#eddc1c"
border.width: 1
radius: 180
}
}
RoundButton {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: parent.width / 8
Layout.maximumHeight: parent.height / 8
id: d1
text: "D"
background: Rectangle {
implicitHeight: 35
implicitWidth: 35
color: d1.down ? "#7207ed" : "transparent"
border.color: "#7207ed"
border.width: 1
radius: 180
}
}
RoundButton {
id: w1
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: parent.width / 8
Layout.maximumHeight: parent.height / 8
text: "W"
background: Rectangle{
implicitHeight: 35
implicitWidth: 35
color: w1.down ? "#1dbf32" : "transparent"
border.color: "#1dbf32"
border.width: 1
radius: 180
}
}
RoundButton {
id: l1
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: parent.width / 8
Layout.maximumHeight: parent.height / 8
text: "L"
background: Rectangle{
implicitHeight: 35
implicitWidth: 35
color: l1.down ? "#e6050c" : "transparent"
border.color: "#e6050c"
border.width: 1
radius: 180
}
}
}

View file

@ -1,7 +0,0 @@
[Package]
bin = "main"
name = "test"
version = "0.1.0"
[Deps]
Requires: "nim >= 1.2.0, nimqml >= 0.9.0"