Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netrunner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Odilitime
netrunner
Commits
9bb645ec
Commit
9bb645ec
authored
7 years ago
by
Odilitime
Browse files
Options
Downloads
Patches
Plain Diff
don't require an URL on start
parent
514fc965
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.cpp
+33
-26
33 additions, 26 deletions
src/main.cpp
with
33 additions
and
26 deletions
src/main.cpp
+
33
−
26
View file @
9bb645ec
...
...
@@ -46,45 +46,52 @@ bool fileExists(const std::string s) {
}
int
main
(
int
argc
,
char
*
argv
[])
{
// no longer require a URL
/*
if (argc == 1) {
std
::
cout
<<
"./netrunner
<url|
file.html
>
[-log <error|warning|notice|info|debug>]"
<<
std
::
endl
;
std::cout << "./netrunner
[http://host.tld/|/path/to/
file.html
]
[-log <error|warning|notice|info|debug>]" << std::endl;
return 1;
}
*/
std
::
cout
<<
"/g/ntr - NetRunner build "
<<
__DATE__
<<
std
::
endl
;
initCLParams
(
argc
,
argv
);
std
::
string
rawUrl
=
getCLParamByIndex
(
1
);
// if we do this here, shouldn't we do this in parseUri too?
if
(
rawUrl
.
find
(
"://"
)
==
rawUrl
.
npos
)
{
// Path should always be absolute for file://
if
(
isAbsolutePath
(
rawUrl
))
{
rawUrl
=
"file://"
+
rawUrl
;
}
else
{
auto
absolutePath
=
std
::
string
(
getenv
(
"PWD"
))
+
'/'
+
rawUrl
;
if
(
fileExists
(
absolutePath
))
{
rawUrl
=
"file://"
+
absolutePath
;
}
else
{
// Default to http if the file wasn't found
rawUrl
=
"http://"
+
rawUrl
;
}
}
}
// we need to set up OGL before we can setDOM (because component can't be constructed (currently) without OGL)
// but should be after CommandLineParams incase we need to change some type of window config
window
->
windowWidth
=
1024
;
window
->
windowHeight
=
640
;
window
->
init
();
if
(
!
window
->
window
)
{
return
1
;
}
//logDebug() << "pre URL parse [" << url << "]" << std::endl;
window
->
currentURL
=
URL
(
rawUrl
);
logDebug
()
<<
"loading ["
<<
window
->
currentURL
<<
"]"
<<
std
::
endl
;
if
(
!
setWindowContent
(
window
->
currentURL
))
{
return
1
;
//std::cout << "argc " << argc << std::endl;
if
(
argc
>
1
)
{
initCLParams
(
argc
,
argv
);
// this isn't going to work
std
::
string
rawUrl
=
getCLParamByIndex
(
1
);
// if we do this here, shouldn't we do this in parseUri too?
if
(
rawUrl
.
find
(
"://"
)
==
rawUrl
.
npos
)
{
// Path should always be absolute for file://
if
(
isAbsolutePath
(
rawUrl
))
{
rawUrl
=
"file://"
+
rawUrl
;
}
else
{
auto
absolutePath
=
std
::
string
(
getenv
(
"PWD"
))
+
'/'
+
rawUrl
;
if
(
fileExists
(
absolutePath
))
{
rawUrl
=
"file://"
+
absolutePath
;
}
else
{
// Default to http if the file wasn't found
rawUrl
=
"http://"
+
rawUrl
;
}
}
}
//logDebug() << "pre URL parse [" << url << "]" << std::endl;
window
->
currentURL
=
URL
(
rawUrl
);
logDebug
()
<<
"loading ["
<<
window
->
currentURL
<<
"]"
<<
std
::
endl
;
if
(
!
setWindowContent
(
window
->
currentURL
))
{
return
1
;
}
}
while
(
!
glfwWindowShouldClose
(
window
->
window
))
{
//const std::clock_t begin = clock();
window
->
render
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment